From help-request at octave dot org Sat Feb 19 23:56:40 2005 Subject: C++ style: variable names, white space, etc. From: "Steve C. Thompson" To: help at octave dot org Date: Sat, 19 Feb 2005 21:58:37 -0800 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 #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 -------------------------------------------------------------