help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

C++ style: variable names, white space, etc.


From: Steve C. Thompson
Subject: C++ style: variable names, white space, etc.
Date: Sat, 19 Feb 2005 21:58:37 -0800
User-agent: Mutt/1.3.28i

Hello,

First off, thanks for the help with the C++.
(http://www.octave.org/mailing-lists/help-octave/2005/445)

I now have some simple examples working!

Please give some pointers on style.  I've read from the GNU Coding
Standards (http://www.gnu.org/prep/standards/) that it is best to use
lowercase variables, and plenty of white space. It suggests spelling out
variable names and avoiding abbreviations when possible.

I took this to the extreme with this example:

------------------------------------------------

#include <octave/oct.h>
#define PI 3.14159265358979
DEFUN_DLD (sct_complex_matrix, args, , "Returns a complex matrix")
{
        octave_value retval;
        int subcarrier_number = 128;
        int oversample_factor = 4;
        int sample_per_block = subcarrier_number * oversample_factor;
        ComplexMatrix subcarrier_matrix(
                        subcarrier_number,
                        sample_per_block );
        for (int n = 0 ; n < sample_per_block ; n++)
  {
                for (int k = 0 ; k < subcarrier_number ; k++)
                {
                        subcarrier_matrix(n,k)=
                                Complex(
                                                cos( 2 * PI * n * k / 
subcarrier_number),
                                                sin( 2 * PI * n * k / 
subcarrier_number) );
                }
        }
        return retval = subcarrier_matrix;
}

------------------------------------------------

I think that it reads OK.  In fact, I like how the variables are so
clear.

Any suggestions? Do you suggest a good text?

Also, I have started a page that documents my C++ examples.  Hopefully,
in time, it will be helpful to others with minimal coding experience.
(http://elsteve.com/techart/sct_complex_matrix_art/)

Thanks,
Steve



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]