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
 Error using convolution fit

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
jeplb Posted - 10/10/2015 : 05:32:28 AM
Origin Ver. and Service Release (Select Help-->About Origin): 9.0
Operating System: Mac OS X El Capitan, Parallels Desktop Windows 7

I am having issues regarding the convolution algorithm that can be found in the wiki. It keeps giving me an error "Vector operation dimension check error". My suspicion is that the step size of my x-values is not the same as the example (tutorial: step size of 0.1; mine is 0.07). I was wondering if there is a workaround for this.
4   L A T E S T    R E P L I E S    (Newest First)
natashatabassum Posted - 02/06/2016 : 1:43:03 PM
Hello,
I am trying to use the above mentioned Convolution fit function in OrininPro2015 in windows 10. I am still getting the "Vector operation dimension check error".
I am using the sample data that it came with. I am not sure what can be the problem.

Thanks
SeanMao Posted - 10/12/2015 : 11:43:34 PM
Hi,

This is correct, but you need to be careful when you choose initial values for fitting parameters.

Regards!

Sean
jeplb Posted - 10/12/2015 : 8:06:36 PM
Hey Sean,

Calculating dx first solves the problem!

I was wondering, say, if I want to fit a double exponential I should just change the line:
vSignal = A * exp( -(vSample-vSample[0])/t1 );

to

vSignal = A * exp( -(vSample-vSample[0])/t1 ) + B * exp( -(vSample-vSample[0])/t2 );

Is that correct?
SeanMao Posted - 10/12/2015 : 05:27:28 AM
Hi,

Can you try the following code instead?


#pragma numlittype(push, TRUE)
#pragma numlittype(push, TRUE)
#pragma numlittype(push, TRUE)
#pragma numlittype(push, TRUE)
#pragma numlittype(push, TRUE)
#pragma numlittype(push, TRUE)
#pragma warning(error : 15618)
#include <origin.h>
#include <ONLSF.H>
#include <fft_utils.h>
// 
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
		Worksheet wks = Project.ActiveLayer();
	NLFitContext *pCtxt = Project.GetNLFitContext();
	if ( pCtxt )
	{	
		// Vector for the output signal in each iteration.
		static vector vSignal;
		static double dx;
		// 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;
	 
			dx = vSample[1] - vSample[0];
			
			vSignal.SetSize(iSize);
			vResponse.SetSize(iSize);
			vSample.SetSize(iSize);
	 
			// Compute the exponential decay curve
			vSignal = A * exp( -t*(vSample-vSample[0]) );
			// Perform convolution
			int iRet = fft_fft_convolution(iSize, vSignal, vResponse);
	 
		}
	 
		NLSFCURRINFO    stCurrInfo;
		pCtxt->GetFitCurrInfo(&stCurrInfo);
		// Get the data index for the iteration
		int nCurrentIndex = stCurrInfo.nCurrDataIndex;
		// Get the evaluated y value
		y = dx*vSignal[nCurrentIndex] + y0;
		// For compile the function, since we haven't use x here.
		x;
	}
	// End of editable part
}


When you use it to fit convolution in NLFit dialog, you need to notice:

1. In NLFit dialog, make sure the worksheet for source data active.
2. In NLFit dialog, X data for fitted curve should be Same as Input Data.

Regards!

Sean

OriginLab Technical Service

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