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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Error, Pragma syntax error.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Victor_Y18

Australia
2 Posts

Posted - 10/27/2015 :  11:56:09 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I am trying to fit my data with convolution and basically I copied code from http://www.originlab.com/doc/Tutorials/Fitting-Convolution.

My code is as following:

#pragma numlittype(push, TRUE)
#pragma warning(error : 15618)
#include <origin.h>
#include <ONLSF.H>
#include <fft_utils.h>
// Add your special include files here.
// For example, if you want to fit with functions from the NAG library,
// add the header file for the NAG functions here.

// Add code here for other Origin C functions that you want to define in this file,
// and access in your fitting function.

// You can access C functions defined in other files, if those files are loaded and compiled
// in your workspace, and the functions have been prototyped in a header file that you have
// included above.

// You can access NLSF object methods and properties directly in your function code.

// You should follow C-language syntax in defining your function.
// For instance, if your parameter name is P1, you cannot use p1 in your function code.
// When using fractions, remember that integer division such as 1/2 is equal to 0, and not 0.5
// Use 0.5 or 1/2.0 to get the correct value.

// For more information and examples, please refer to the "User-Defined Fitting Function"
// section of the Origin Help file.





//----------------------------------------------------------
//
void _nlsfFitConv(
// Fit Parameter(s):
double y0, double A, double t,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
// Beginning of editable part
NLFitContext *pCtxt = Project.GetNLFitContext();
Worksheet wks;
DataRange dr;
int c1,c2;
dr = pCtxt->GetSourceDataRange(); //Get the source data range
dr.GetRange(wks, c1, c2); //Get the source data worksheet
if ( pCtxt )
{
// Vector for the output signal in each iteration.
static vector vSignal;
// If parameters were updated, we will recalculate the convolution result.
BOOL bIsNewParamValues = pCtxt->IsNewParamValues();
if ( bIsNewParamValues )
{
// Read sampling and response data from worksheet.
Dataset dsSampling(wks, 0);
Dataset dsResponse(wks, 2);
int iSize = dsSampling.GetSize();

vector vResponse, vSample;

vResponse = dsResponse;
vSample = dsSampling;

vSignal.SetSize(iSize);
vResponse.SetSize(iSize);
vSample.SetSize(iSize);

// Compute the exponential decay curve
vSignal = A * exp( -t*vSample );
// Perform convolution
int iRet = fft_fft_convolution(iSize, vSignal, vResponse);
//Correct the convolution by multiplying the sampling interval
vSignal = (vSample[1]-vSample[0])*vSignal;


}

NLSFCURRINFO stCurrInfo;
pCtxt->GetFitCurrInfo(&stCurrInfo);
// Get the data index for the iteration
int nCurrentIndex = stCurrInfo.nCurrDataIndex;
// Get the evaluated y value
y = vSignal[nCurrentIndex] + y0;
// For compile the function, since we haven't use x here.
x;
}



// End of editable part
}

But during compiling, the "Pragma syntax error" error shows up. Can anyone help me on that? Thanks a lot.

SeanMao

China
288 Posts

Posted - 10/28/2015 :  02:22:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

If you are using Origin 2015 or earlier version, you can use the code I replied on this post instead:

http://www.originlab.com/forum/topic.asp?TOPIC_ID=21759

I have tested this code in Origin 2015 and no errors showed up.

The code you copied from the link you have provided only works in Origin 2016 since function GetSourceDataRange() is newly introduced. I have tested in Origin 2016 SR0 and no errors came up.

Give it a try of the code in the post I have attached and see how it goes.

Regards!

Sean

OriginLab Tech. Service

Edited by - SeanMao on 10/28/2015 02:26:12 AM
Go to Top of Page

Victor_Y18

Australia
2 Posts

Posted - 10/28/2015 :  03:49:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Sean,

I've copied your code but still I got the same problem, pragma syntax error. I am using the origin 8. Will that be a problem?

Best,
Jiong

quote:
Originally posted by SeanMao

Hi,

If you are using Origin 2015 or earlier version, you can use the code I replied on this post instead:

http://www.originlab.com/forum/topic.asp?TOPIC_ID=21759

I have tested this code in Origin 2015 and no errors showed up.

The code you copied from the link you have provided only works in Origin 2016 since function GetSourceDataRange() is newly introduced. I have tested in Origin 2016 SR0 and no errors came up.

Give it a try of the code in the post I have attached and see how it goes.

Regards!

Sean

OriginLab Tech. Service

Go to Top of Page

SeanMao

China
288 Posts

Posted - 10/28/2015 :  04:27:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I have successfully compiled the code in another post in OriginPro 8 with no error showed up:



I am not quite sure why it does not work on your side.

Regards!

Sean
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000