Questions tagged [numerical-recipes]

Numerical Recipes is the generic title of a series of books on algorithms and numerical analysis by four University of Cambridge professors. The algorithms are available in FORTRAN, C, C++, and Java.

Numerical Recipes is the generic title of a series of books on algorithms and numerical analysis by four University of Cambridge professors: William H. Press, Saul A. Teukolsky, William T. Vetterling and Brian P. Flannery. There are editions available for Fortran, C, and C++.

18 questions
2
votes
1 answer

Class method type

I am writing a code using the numerical recipes library and I would like to minimize a function which is actually the method of a class. I have this type of code: class cl{ Doub instance(VecDoub_I &x) { return x[0]*x[0] + x[1]*x[1]; …
Robin Nicole
  • 646
  • 4
  • 17
1
vote
1 answer

Example on FFT from Numerical Recipes book results in runtime error

I am trying to implement the FFT algorithm on C. I wrote a code based on the function "four1" from the book "Numerical Recipes in C". I know that using external libraries such as FFTW would be more efficient, but I just wanted to try this as a first…
Olayo
  • 13
  • 3
1
vote
1 answer

Fortran undefined reference to _[subroutine name]

I'm testing out Numerical Recipies in Fortran 90 vol2 helloBessel as written in the book. program helloBessel use nrtype use nr, ONLY: flmoon, bessj0 implicit none integer(I4B) :: n = 200, nph = 2, jd real(SP) :: x, frac, ans call flmoon(n, nph,…
tRash
  • 131
  • 1
  • 11
1
vote
1 answer

Question on book Numerical recipes, 2nd ed.: allocation/deallocation of memory for vectors

The book Numerical recipes, 2nd edition (http://numerical.recipes) uses the following code to allocate/deallocate a memory for a vector v with subscripts [nl..nh]: #define NR_END 1 #define FREE_ARG char* float *vector(long nl, long nh) /* allocate…
Dmitry Kabanov
  • 710
  • 1
  • 7
  • 20
1
vote
1 answer

Why are there no include guards in Numerical Recipes header files?

novice C++ programmer here. I'm using Numerical Recipes (V3) source code as part of a larger, modulated C++ project. While I'll try not to get into the specifics of my problem, I am curious as to why these NR header files do not incorporate any…
1
vote
0 answers

Error from wrapping GSL in Cython: Cannot convert Python object to 'double (*)(double, void *) nogil'

First of all, please do excuse my poor use of programming terminology and bad (or even completely wrong) programming practices; i am still trying to find my feet :-) In summary, i am trying to write a version of the multidimensional integration…
Zhong Yuan Lai
  • 123
  • 1
  • 6
1
vote
1 answer

Replace Numerical Recipe's dmatrix with a C++ class

I'm revamping an old application that use Numerical Recipes' dmatrix quite extensively. Since one of the reasons I'm working on the application is because its code is about to be opened, I want to replace all of the Numerical Recipes code with code…
zmbq
  • 38,013
  • 14
  • 101
  • 171
0
votes
0 answers

Getting error while compiling the Fortran code to generate Gaussian random numbers

program Gaussian_random_number implicit none integer, parameter :: N = 1000 integer, parameter :: idum = -123456789 real(kind=8), parameter :: AA = 0.1d0 real(kind=8) :: noise double precision::ran2,gasdev integer :: i do i =…
0
votes
0 answers

Convergence rate adaptive Runge Kutta methods

I have a system of ODEs and I solve them with two different algorithms: A normal, constant stepsize, Runge Kutta 4 implementation A modified Runge Kutta 4, with variable stepsize control My professor asked me to make a plot showing convergences…
0
votes
1 answer

Fortran compiler differences in treating properties as 'save attributes'?

We have this old Fortran script that we're trying to recompile using Intel's Visual Fortran but we get calculation errors and different results than the old compiled version of the code. We found what we believe to be the problem in the code below…
Petter
  • 321
  • 3
  • 9
0
votes
1 answer

C# numerical recipes

im begginer in C# and programming in general and i want to ask. I'm trying to make a project with datagridview in it and some calculations. Basicly what i want to do is from table of empirical data aproximate the data with chebyshev aproximation.…
L.Johnson
  • 79
  • 2
  • 11
0
votes
1 answer

indexx() Numerical Recipes (C) index sorting algorithm weirdly ignoring first two elements

I am trying to use the indexx() algorithm from Numerical Recipes (NR) in C and have found a very strange bug. (NR is publicly available here: http://www2.units.it/ipl/students_area/imm2/files/Numerical_Recipes.pdf page 338, section 8.4) The…
zooombini
  • 143
  • 2
  • 12
0
votes
1 answer

Numerical Recipes in fortran 90 ran_init integer model assumption

The ran_init subrroutine of the Numerical Recipes contains this lines: INTEGER(K4B) :: new,j,hgt ... hgt=hg ... if (hgt+1 /= hgng) call…
alexis
  • 410
  • 4
  • 18
0
votes
1 answer

template instantiation issue with complex data types

I have the type of parameters as typedef double DP; typedef const NRVec Vec_I_DP; //NRVec is a parametrized template class. typedef NRVec Vec_DP, Vec_O_DP, Vec_IO_DP; xa -> Vec_I_DP(30) ya -> Vec_I_DP(30) yp1 -> DP(30) ypn -> DP(30) y2 ->…
asit_dhal
  • 1,239
  • 19
  • 35
0
votes
0 answers

linker error in numerical recipe

My situation is I have a one file c++ code and it uses numerical recipe library. I have included all numerical recipe files in "Additional Include Directories" nr.h nrexit.cpp nrtypes.h nrtypes_lib.h nrtypes_nr.h nrutil.h nrutil_mtl.h…
asit_dhal
  • 1,239
  • 19
  • 35
1
2