[Top][All Lists]

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

what's wrong with this code?

From: heberf
Subject: what's wrong with this code?
Date: Sat, 20 Feb 1999 01:03:11 -0600 (CST)

I'm not a C++ wizard but I write .oct files from time to time.  Usually it
works fine but today I wrote a new one and it causes octave to dump core.
I kept simplifying it to figure out where the problem is but no luck.
Now it's down to just a few lines and stil has the same problem but I
don't see it.  The code is below.  Put this in a file called
Compile it with mkoctfile and it compiles with no errors.  Now do the

octave:1> dw = randn(9000,1);
octave:2> [a b] = showit(.08,.08,dw); 

and it dumps core.  Any ideas?

#include <octave/oct.h>

DEFUN_DLD (showit, args, ,"Does this work?")

  octave_value_list retval;

  double r0 = args(0).double_value();
  double theta = args(1).double_value();
  ColumnVector dw = args(2).vector_value();

  int NumberElements = dw.length();
  ColumnVector r(NumberElements,0);
  ColumnVector Target(NumberElements,0);
  r(0) = r0;
  Target(0) = theta;
  for (int i=0; i < NumberElements; i++)
      Target(i+1) = Target(i);  
      r(i+1)=r(i) + dw(i+1);
  retval(0) = octave_value (r);
  retval(1) = octave_value (Target);
  return retval; 

Heber Farnsworth
Assistant Professor of Finance
John M. Olin School of Business
Washington University
Campus Box 1133                                 phone: (314) 935-4221   
One Brookings Drive                             FAX: (314) 935-6359
St. Louis, MO 63130-4899                

reply via email to

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