help-octave
[Top][All Lists]
Advanced

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

Using Vim, using tabs, using spaces


From: Steve C. Thompson
Subject: Using Vim, using tabs, using spaces
Date: Sat, 19 Feb 2005 22:21:05 -0800
User-agent: Mutt/1.3.28i

Group,

This leads me to the next question.

The last post I made came back looking like ass.  The tabs in Vim looked
fine on my computer. Do you guys use Vim to write your Octave code (I
have the feeling that JWE prefers Emacs).  Is tabbing good practice or
using spaces?  From my experience, tabbing can get you into trouble --
the previous post is a case in point.

Below is the program with spaces.

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

#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;
}

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

Now with tabbing.

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

#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;
}

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

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]