473,698 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

new to Numerical Recipies

Hi all,

I am trying to make a sinusoidal curve fit by using Levenberg-Marquardt
Method with numerical recipies.

I have model the my function which is y=Ao+C1.cos(x+p hase) as at the end of
this message.

From that point on I am confused about what to do. I know I need to use
mrqcof function but could not figure it out how to use use it becase the
function looks like more advaced to me which is

void mrqcof(float x[], float y[], float sig[], int ndata, float a[], int
ia[],

int ma, float **alpha, float beta[], float *chisq,

void (*funcs)(float, float [], float *, float [], int))

I am using Visual Studio.Net 2003 so I have transfered this function as

typedef void (*funcs)(float, float [],float *,float [],int);

void mrqcof(float x[], float y[], float sig[], int ndata, float a[], int
ia[],int ma, float **alpha, float beta[], float *chisq,funcs MyComp);

Now I do not know what to do?

Can anyone help me or forward me to some examples? I could not find much on
the internet by myself..

Thanks....

void model(float x, float a[], float *y, float dyda[], int na)

{

float fac,Mcos,Msin;

*y=0.0;

for(int i=1;i<na-1;i+=3)

{

Mcos=cos(x+a[i+2]);

Msin=sin(x+a[i+2]);

fac=-a[i+1]*sin(x+a[i+2]);

*y+=a[i]+(a[i+1]*Mcos);

dyda[i]=1;

dyda[i+1]=Mcos-(a[i+1]*Msin);

dyda[i+2]=-a[i+1]*Msin;

}
Jul 22 '05 #1
6 2451
As an adition I got this from the compile window at VS.NET 2003
DOIT error LNK2019: unresolved external symbol "void __cdecl mrqcof(float *
const,float * const,float * const,int,float * const,int * const,int,float *
*,float * const,float *,void (__cdecl*)(floa t,float * const,float *,float *
const,int))" (?mrqcof@@YAXQA M00H0QAHHPAPAM0 PAMP6AXM030H@Z@ Z) referenced in
function _main
Jul 22 '05 #2
kak3012 wrote:
As an adition I got this from the compile window at VS.NET 2003
DOIT error LNK2019: unresolved external symbol "void __cdecl mrqcof(float *
const,float * const,float * const,int,float * const,int * const,int,float *
*,float * const,float *,void (__cdecl*)(floa t,float * const,float *,float *
const,int))" (?mrqcof@@YAXQA M00H0QAHHPAPAM0 PAMP6AXM030H@Z@ Z) referenced in
function _main


This appears to be a linking error. Probable reasons could be -

.. you are missing a library to be linked against your application.
.. you had misspelled the prototype of the function.

Anyway, we discuss the C++ core programming language in this
newsgroup. And this message is off-topic here.

For that matter, this might be off-topic to comp.lang.c too.

sci.math.num-analysis might be the best place to look for these things.
--
Karthik.
Jul 22 '05 #3
Hi,

thanks for the comment.

What is core C++?

Regards...
"Karthik Kumar" <ka************ *******@yahoo.c om>, iletide sunu yazdi
news:41f37746$1 @darkstar...
kak3012 wrote:
As an adition I got this from the compile window at VS.NET 2003
DOIT error LNK2019: unresolved external symbol "void __cdecl mrqcof(float * const,float * const,float * const,int,float * const,int * const,int,float * *,float * const,float *,void (__cdecl*)(floa t,float * const,float *,float * const,int))" (?mrqcof@@YAXQA M00H0QAHHPAPAM0 PAMP6AXM030H@Z@ Z) referenced in function _main


This appears to be a linking error. Probable reasons could be -

. you are missing a library to be linked against your application.
. you had misspelled the prototype of the function.

Anyway, we discuss the C++ core programming language in this
newsgroup. And this message is off-topic here.

For that matter, this might be off-topic to comp.lang.c too.

sci.math.num-analysis might be the best place to look for these things.
--
Karthik.

Jul 22 '05 #4
kak3012 wrote:
Hi,

thanks for the comment.

What is core C++?

Regards...

[thread snipped]

The C++ language and the functions and libraries as defined by the C++
standard are the only things that are topical here.
Hope that clarifies my message.

--
Karthik.
Jul 22 '05 #5

"kak3012" <s0*****@studen t.dtu.dk> wrote in message
news:cs******** **@gnd.k-net.dk...
Hi all,

I am trying to make a sinusoidal curve fit by using Levenberg-Marquardt
Method with numerical recipies.

I have model the my function which is y=Ao+C1.cos(x+p hase) as at the end of this message.

From that point on I am confused about what to do. I know I need to use
mrqcof function but could not figure it out how to use use it becase the
function looks like more advaced to me which is

void mrqcof(float x[], float y[], float sig[], int ndata, float a[], int
ia[],

int ma, float **alpha, float beta[], float *chisq,

void (*funcs)(float, float [], float *, float [], int))

I am using Visual Studio.Net 2003 so I have transfered this function as

typedef void (*funcs)(float, float [],float *,float [],int);

void mrqcof(float x[], float y[], float sig[], int ndata, float a[], int
ia[],int ma, float **alpha, float beta[], float *chisq,funcs MyComp);

Now I do not know what to do?

Can anyone help me or forward me to some examples? I could not find much on the internet by myself..

Thanks....

void model(float x, float a[], float *y, float dyda[], int na)

{

float fac,Mcos,Msin;

*y=0.0;

for(int i=1;i<na-1;i+=3)

{

Mcos=cos(x+a[i+2]);

Msin=sin(x+a[i+2]);

fac=-a[i+1]*sin(x+a[i+2]);

*y+=a[i]+(a[i+1]*Mcos);

dyda[i]=1;

dyda[i+1]=Mcos-(a[i+1]*Msin);

dyda[i+2]=-a[i+1]*Msin;

}


If you ad the file "mrqcof.c" to your project, the linker error should be
resolved. Since "mrqcof.c" starts with an include "NrUtil.h", there could be
a "nrutil.c" you need to add too..

I found a version online.. There are probably alot:
#define NRANSI

#include "nrutil.h"

void mrqcof(float x[], float y[], float sig[], int ndata, float a[], int
ia[],

int ma, float **alpha, float beta[], float *chisq,

void (*funcs)(float, float [], float *, float [], int))

{

int i,j,k,l,m,mfit= 0;

float ymod,wt,sig2i,d y,*dyda;

dyda=vector(1,m a);

for (j=1;j<=ma;j++)

if (ia[j]) mfit++;

for (j=1;j<=mfit;j+ +) {

for (k=1;k<=j;k++) alpha[j][k]=0.0;

beta[j]=0.0;

}

*chisq=0.0;

for (i=1;i<=ndata;i ++) {

(*funcs)(x[i],a,&ymod,dyda,m a);

sig2i=1.0/(sig[i]*sig[i]);

dy=y[i]-ymod;

for (j=0,l=1;l<=ma; l++) {

if (ia[l]) {

wt=dyda[l]*sig2i;

for (j++,k=0,m=1;m< =l;m++)

if (ia[m]) alpha[j][++k] += wt*dyda[m];

beta[j] += dy*wt;

}

}

*chisq += dy*dy*sig2i;

}

for (j=2;j<=mfit;j+ +)

for (k=1;k<j;k++) alpha[k][j]=alpha[j][k];

free_vector(dyd a,1,ma);

}

#undef NRANSI

/* (C) Copr. 1986-92 Numerical Recipes Software M2&. */
Jul 22 '05 #6
kak3012 wrote:
Hi all,

I am trying to make a sinusoidal curve fit by using Levenberg-Marquardt
Method with numerical recipies.

I have model the my function which is y=Ao+C1.cos(x+p hase) as at the end of
this message.

From that point on I am confused about what to do. I know I need to use
mrqcof function but could not figure it out how to use use it becase the
function looks like more advaced to me which is

void mrqcof(float x[], float y[], float sig[], int ndata, float a[], int
ia[],

int ma, float **alpha, float beta[], float *chisq,

void (*funcs)(float, float [], float *, float [], int))

[redacted]


Not no the subject of your link error, but you really should use double
instead of float.

Especially since you are using VC. Float gives you 23 bits of
precision, double gives you 53.
Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1631
by: Rob Miller | last post by:
A new book with a numerical library in Java was published in August 2003. Title: "A Numerical Library in Java for Scientists and Engineers" Author: Hang T. Lau ISBN: 1584884304 Published date: August 2003 publisher: CRC Press email: orders@crcpress.com
9
2673
by: Carl | last post by:
I have been using Python for quite some time now and I love it. I use it mainly for explorative computing and numerical prototyping, ie testing and trying out different kinds of algorithms and computational schemes. The use of Python as my first-choice language has made me extremely productive. Now, I have always believed that Python is a poor performer in terms of numerical speed. My experience, however, is that the efficient use of...
81
5145
by: Jonas Smithson | last post by:
I recently read the claim somewhere that numerical entities (such as —) have a speed advantage over the equivalent named entities (such as &mdash;) because the numerical entity requires just a single byte to be downloaded to the browser, while the named entity requires one byte for each letter. (So in this case, it would presumably be one byte vs. seven bytes.) I found this claim a little surprising -- I would have thought *each* numeral...
2
2020
by: Martin McCormick | last post by:
Most of the C programming I write manipulates strings so I haven't had much experience with numerical functions and passing variables in and out which brings me to a laughably simple problem that I am having. How does one pass two unsigned longs in to a function that will ultimately do floating point calculations on them? A C tutorial I have says that one should not declare the inputs to a function as floats but should use doubles which...
2
1814
by: Josema | last post by:
Hi to all, I have a datagrid filled with string values, and when i click in a header column the datagrid is alphanumerical sorted , but i need sort some columns by numeric way... The datasource of this Datagrid is a DataView, that is a View of a DataTable (using the property of the datatable.CurrentView) Do you know how could i solve the sorting problem to have a numerical sort,
16
3264
by: Martin Jørgensen | last post by:
Hi, I've made a program from numerical recipes. Looks like I'm not allowed to distribute the source code from numerical recipes but it shouldn't even be necessary to do that. My problem is that I'm not very experienced with pointers, pointers to pointers and the like and I got 4 compiler warnings + I don't completely understand how to build this "compact matrix" (see later).
23
15664
by: Abhi | last post by:
Hi.. I wanted the C source code in machine readable format for the book "Numerical Recipes in C". I got hold of the pdf version of the book somehow. Does anyone have the complete C code of the book?. If yes,..can you please mail me the code or somehow share it with me?. With Regards, Abhishek S
10
5419
by: Babak | last post by:
Hi, I've developed a C program which contains a large number of vectors and matrices operations. Throughout my code, I used the template from the Numerical Recipes book to define vectors and matrices and access their elements. For example, to define a vector I used the function: my_vector=vector(0,n-1); Which actually allocate the memory as follows:
1
1367
by: mfaisal16 | last post by:
Repected members, I need help regarding using Numerical Recipies (www.nr.com) code of c++. Any body have expereicne in this field.... waiting for you reply.. regards, Muhammad Faisal Phd Student.
0
8672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9155
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7711
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5859
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3038
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.