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
 Origin Forum
 Error, Pragma syntax error.

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
Victor_Y18 Posted - 10/27/2015 : 11:56:09 PM
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.
3   L A T E S T    R E P L I E S    (Newest First)
SeanMao Posted - 10/28/2015 : 04:27:12 AM
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
Victor_Y18 Posted - 10/28/2015 : 03:49:39 AM
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

SeanMao Posted - 10/28/2015 : 02:22:35 AM
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

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