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 for Programming
 Forum for Origin C
 interpolation
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

couturier

France
291 Posts

Posted - 11/06/2017 :  11:28:21 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2017SR2
Operating System:win10

Hi,

I'm trying to find the LT copy -s equivalent operation in OriginC:
I have a vector with N1 pts, and I'd like this vector to become N2 pts, without the need of specifying an input and output X vector.

Thanks for your help

Castiel

343 Posts

Posted - 11/06/2017 :  10:43:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by couturier

Origin Ver. and Service Release (Select Help-->About Origin): 2017SR2
Operating System:win10

Hi,

I'm trying to find the LT copy -s equivalent operation in OriginC:
I have a vector with N1 pts, and I'd like this vector to become N2 pts, without the need of specifying an input and output X vector.

Thanks for your help




Simply apply the linear interpolation to your data.

bool lt_copy_s(vector<double>& values, size_t npts)
{
    size_t nSrcSize = values.GetSize();
    vector<double> SrcX;
    SrcX.Data(0.0, nSrcSize - 1, 1.0);

    vector<double> X, Y;
    double delta = (values.GetSize() - 1.0) / (npts - 1.0);
    X.Data(0.0, values.GetSize() - 1, delta);
    Y.SetSize(X.GetSize());

    int nRet = ocmath_interpolate(X, Y, npts, SrcX, values, nSrcSize);
    if(nRet != OE_NOERROR)
        return false;
    values = Y;

    return true;
}




     #####
    #### _\_  ________
    ##=-[.].]| \      
    #(    _\ |  |------|
     #   __| |  ||||||||
      \  _/  |  ||||||||
   .--'--'-. |  | ____ |
  / __      `|__|[o__o]|
_(____nm_______ /____\____ 
Go to Top of Page

couturier

France
291 Posts

Posted - 11/07/2017 :  02:48:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot Castiel.
I was just wondering if I could avoid that step of creating X values.
Go to Top of Page

Castiel

343 Posts

Posted - 11/08/2017 :  08:24:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by couturier

Thanks a lot Castiel.
I was just wondering if I could avoid that step of creating X values.



Why? Does creating X data raise any problem?

vectorbase::Data() behaves in a way quite strange comparing to python or matlab which however has been carefully handled.


     #####
    #### _\_  ________
    ##=-[.].]| \      
    #(    _\ |  |------|
     #   __| |  ||||||||
      \  _/  |  ||||||||
   .--'--'-. |  | ____ |
  / __      `|__|[o__o]|
_(____nm_______ /____\____ 
Go to Top of Page

couturier

France
291 Posts

Posted - 11/10/2017 :  3:03:19 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
No problem at all.
I asked in case I had missed some OC function, allowing faster execution
quote:
vectorbase::Data() behaves in a way quite strange

What do you mean ?
never had any issue
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