[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problems with a linked function
From: |
Markus Michael Rau |
Subject: |
Re: Problems with a linked function |
Date: |
Fri, 22 Jun 2012 16:36:18 -0700 (PDT) |
ok found it out:
#include <octave/oct.h>
DEFUN_DLD(ber_bins_simpson, args, ,"Calculates the integral per redshift bin
call it ber_bins_simpson(f, st). Please note that the components have to be
ODD!!!")
{
octave_value_list retval;
int nargin = args.length();
ColumnVector f(args(0).vector_value());
if(nargin != 2 || args(0).vector_value().length() % 2 == 0)
print_usage();
else
{
ColumnVector st(args(1).vector_value());
ColumnVector bins((st.length()-1)/2);
double *fval = f.fortran_vec();
double *stval = st.fortran_vec();
double *binsval = bins.fortran_vec();
int j = 0;
for(int i = 0; i < (st.length() - 2); i = i + 2){
binsval[j] = (stval[i + 2] - stval[i])/6 * (fval[i] + 4*fval[i + 1] +
fval[i + 2]);
j++;
}
retval.append(octave_value(bins));
return retval;
}
}
--
View this message in context:
http://octave.1599824.n4.nabble.com/Problems-with-a-linked-function-tp4630829p4630892.html
Sent from the Octave - General mailing list archive at Nabble.com.