The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Where is nag_fft_complex in Ver 8?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
artem Posted - 07/24/2009 : 2:18:38 PM
Origin Ver. 8.) and Service Release SR5 (Select Help-->About Origin):
Operating System:Vista Home Basic

I have a NLSF fitting function which uses nag_fft_complex. It works fine in Origin 7.5, but gives an error in my trial version of 8.0. The dialog box Messages tab says:
"There are compilation errors in the fitting function. Please open Code Builder and try to compile to see the errors."

Code builder then produces the following messages:

Linking...
Done!
compiling...
_nlfpch_PWR_c1.fit
C:\Users\pryse\Documents\OriginLab\Origin8\User Files\OriginC\NLSF\_nlfpch_PWR_c1.fit(143) :Error, function or variable nag_fft_complex not found
C:\Users\pryse\Documents\OriginLab\Origin8\User Files\OriginC\NLSF\_nlfpch_PWR_c1.fit(143) :Error, general compile error
C:\Users\pryse\Documents\OriginLab\Origin8\User Files\OriginC\NLSF\_nlfpch_PWR_c1.fit(75) :Error, general compile error
C:\Users\pryse\Documents\OriginLab\Origin8\User Files\OriginC\NLSF\_nlfpch_PWR_c1.fit(27) :Error, error(s) found in compiling function _nlsfpch_PWR_c1
Compile Failed!
Set function fail
OnFunctionChange was called but Function Tree not valid
OnFunctionChange was called but Function Tree not valid

This seems to say that it can't find nag_fft_complex function. The NAG files have different names, etc., in 8.0 compared to 7.5 and it's not clear where the nag_fft_complex function is located in the 8.0 version.

Any ideas?

Thanks,
Tony
10   L A T E S T    R E P L I E S    (Newest First)
larry_lan Posted - 08/05/2009 : 05:19:59 AM
Hi Tony:

We looked into your function and found that you are using some Flag vectors to check whether the parameters are modified. Actually, from Origin 8 SR2, we have introduced the NLFitContext class to record information during fitting. Please read this tutorial to see how to use it.

So, I modified your fitting function body like this (no ig and Fl):

void _nlsfpch_PWR_c1_in_Origin_80(
// Fit Parameter(s):
double c, double q, double p,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
	// Beginning of editable part
	Worksheet wks = Project.ActiveLayer();
	NLFitContext *pCtxt = Project.GetNLFitContext();
	if ( pCtxt )
	{
		// Hard coded, for user's dataset.
		double Ntot = 64;
		double Mtot = 499999;
		// Whether the paremeters are changed
		BOOL bIsNewParamValues = pCtxt->IsNewParamValues();
		// Static vector to hold results
		static vector vHist;
		vHist.SetSize(Ntot);
		// If parameters are changed, calculate vHist
		if ( bIsNewParamValues )
		{			
			int err=0;
			x = x*1.; // Make the compiler happy;
			
			// Initialization for the user define dll function
			vector<double> gRe(Ntot), gIm(Ntot);
			double cv[5], qv[5], BeamParam[12];
			
			for (int ii=0; ii<5; ii++) {
				cv[ii]=0;
				qv[ii]=0;
			}
			for (ii=0; ii<12; ii++) {
				BeamParam[ii]=0;
			}	
			cv[0] = c; qv[0] = q;
			
			BeamParam[0] = 0; BeamParam[1] = p;
			BeamParam[2] = 0;
			BeamParam[11] = 1;
			// End initialization for user define dll function.
			
			// The user define function, got Re and Im part of the complex vector
			err = intPCH(cv, qv, BeamParam, Ntot, gRe, gIm);
			NagError fail;
			// Perform fft
			nag_fft_complex(Ntot, gRe, gIm, &fail);
			// Calculate vHist;
			vHist = Mtot*gRe/sqrt(Ntot);			
		}
		
		// Use the data index to access y values
		// NLSFCURRINFO    stCurrInfo;
		// pCtxt->GetFitCurrInfo(&stCurrInfo);
		// int nCurrentIndex = stCurrInfo.nCurrDataIndex;
		// y = vHist[nCurrentIndex];
		// End Use the data index to access y values
		y = vHist[x]; // Got y value.
	}
	// End of editable part
}


I am not sure whether the result is correct, anyway, I can reproduce the fitted values as Origin 7.5. So please modify the function as you need.

P.S, the "Send E-Mail" link was broken on our forum, so you can email me or contact Iris if you want.

Thanks
Larry
Iris_Bai Posted - 08/03/2009 : 10:35:10 PM
Hi,

Sorry, I made a mistake. Correct the problem you said above with code mark /// Iris IMPROVE_75_FDF_IN_80_MORE.

Please get pch_PWR_c1_80.fdf file from FTP incoming folder again and add by Fitting Function Organizer dialog.

Iris
artem Posted - 08/03/2009 : 2:16:29 PM
Iris,

I retrieved your modified fdf, added it with the Fitting Function Organizer, but still get errors similar to the earlier post:

Invalid column name: SUM([FFS3A]FFS3A!B)
Vector operation dimension check error
(repeated many times)

Fit does not converge, number of points is 0, dof is 0, and Mtot and Ntot are zero after running the fit.

Maybe the problem is in the execution of the limit and sum functions:
LT_execute("limit %N");
LT_execute("sum(%M)"); ????
The only way I've gotten the sum function to work in the command window is with sum(ffs3a_b), but not with many other variants:
sum([ffs3a]ffs3a!b)
sum(%([ffs3a]ffs3a!B))
sum([ffs3a]ffs3a!wcol(3))

Sorry for this prolonged topic, but I really appreciate your help so far. (My evaluation copy of 8.0 runs out in a couple of days, so I'm afraid we may not be able to resolve this in time for me to see how well version 8 really works!)

Thanks,
Tony

Iris_Bai Posted - 07/31/2009 : 04:26:12 AM
Hi Tony,

The reason of your 75 FDF not worked in 80 is nlsf LT object not worked as expected same like in Origin75. The internal fitting mechanism changed, nlsf object will not be used later, we introduced new way to replace. I updated your FDF with code mark /// Iris IMPROVE_75_FDF_IN_80 as begin and ///end IMPROVE_75_FDF_IN_80 as end. My change in FDF included:
1. Include NAG header file and add &fail as the last variable for nag_fft_complex.
2. nlsf.y$ and nlsf.x$ return emtpy, so used __NLData.Range1.Y$ and __NLData.Range1.X$.
3. Replace nlsf.vn with const number 0 or 1, nlsf.vn not worked is a bug, we will fix.

Please following the steps below to do fit:
1. Please download pch_PWR_c1_80.fdf file from ftp://ftp.originlab.com./incoming.
2. Launch Origin8, press F9 to open Fitting Function Organizer dialog (or from Tools menu). Click one category in left list, and click Add button, select pch_PWR_c1_80.fdf file. Click Save button and then Close dialog.
3. Import ffs3a.dat data to worksheet and high light columns. Open Nonlinear Curve Fit dialog, choose newly added pch_PWR_c1_80 function, click Fit until Converged button, turn to Parameters Tab, c is 2.44, q is 3.7
4. Click OK button will generate report.

Iris
artem Posted - 07/30/2009 : 11:31:48 AM
Iris,

Sorry, I failed to tell you the name of the uploaded file! The files are zipped into ffs3a.zip.

There should be 5 files in the zip:
1) ffs3a.dll is an externally compiled function which calculates intPCH. intPCH does the heavy-duty computation. (I can send you that code, but you shouldn't need it to debug the fdf.)
2) ffs3a.dat is a data file for fitting with one X col and one Y col. For this data set, let parameters c and q vary, and set p=1.0 (fixed), F1=0 (fixed) and ig=0 (fixed). I fit this data using pch_PWR_c1.fdf in version 7.5 and got c=2.44 and q=3.70.
3) ffs3a.h is the associated header file.
4) pch_PWR_c1.fdf is the function definition file which is surely the culprit giving the errors in 8.0.
5) ffs3areadme.txt (explaining all this)

Sorry for that confusion and thanks again,
Tony
Iris_Bai Posted - 07/29/2009 : 9:43:41 PM
Hi Tony,

Sorry, I not found your uploaded files in incoming folder under ftp://ftp.originlab.com. Could you upload again? And then send file names to me. Thanks.

About your change about include NAG files NOT in [ORIGIN C FUNCTION HEADER] section, I supposed you add Origin7 FDF file by Fitting Function Organizer dialog Add Button, if so, will add function via file browser and save to UserFileFolder\FitFunc\ folder. So the change will be save to the new one FDF file under UserFileFolder\FitFunc\.

Iris
artem Posted - 07/29/2009 : 12:41:13 PM
Hi Iris,

I uploaded the requested files, but the pch_PWR_c1.fdf file that I included may not be the current or proper version. The file in my fitfunc folder is the one I uploaded, and if I look at it with Notepad the lines
#include <NAG8\nag.h>
#include <NAG8\nagc06.h>
are NOT there in the [ORIGIN C FUNCTION HEADER] section, but when I edit that function in code builder, those include lines ARE present in nlfpch_PWR_c1.fit. Those are the include files that I needed to get the function to compile properly. I guess when the function is edited in code builder, the original fdf is not changed??

Sorry for any confusion this may cause.

Thanks,
Tony Pryse
Iris_Bai Posted - 07/28/2009 : 9:54:32 PM
Hi Tony,

Could you send me your fit function file(*.FDF) and data file(*.opj or *.ogw or *.txt or *.dat)? The way to send files please reference to:
http://www.originlab.com/index.aspx?s=1&lm=123&pid=752

Iris
artem Posted - 07/28/2009 : 3:18:08 PM
Thanks Iris,

The proper header for the NAG files and a couple of other tweaks got the function to compile with no errors, but it doesn't run properly in the NLFit window. When I first choose the function, the command window shows the following messages:

Invalid column name: SUM()
Vector operation dimension check error
Vector operation dimension check error
Vector operation dimension check error
(repeated many times)

If I try to fit a data set, the fit does not converge, there are 0 iterations, and a message window pops up with:
"Error! Parameters y0, xc, w and A are not properly initialized. Check their values."

The function does not use these four parameters, so I'm not sure where this comes from.

I'd be happy to use version 7.5 for fitting with this function, but the 7.5 NLSF tool sometimes just freezes up in calculating confidence intervals for the parameters worksheet, and Origin has to be shut down with the Task Manager. I hoped that 8.0 might be more robust in that respect, but it looks like adapting this function to version 8.0 will be a bigger job than I had hoped (and the confidence interval calculation might not be more stable, anyway).

Thanks again,
Tony Pryse
Iris_Bai Posted - 07/27/2009 : 01:09:10 AM
Hi Tony,

The directory of NAG header file changed in Origin8. See the following sample codes:

#include <NAG8\nag.h>
#include <NAG8\nagc06.h>
void testnag(vector& vx, vector vy)
{
	NagError fail;
	nag_fft_complex(vx.GetSize(), vx, vy, &fail);
}


Iris

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000