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
 Call by col(n) of Origin C functions
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

drreaf

Germany
45 Posts

Posted - 12/03/2009 :  05:24:23 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release 7.5 SR6 and 8.0 SR6:
Operating System: XP

What is wrong with this OC code and LabTalk calls:

double CallByCol(string RInm, string RAnm)
{
Int I,n;
Dataset RI,RA;
//return(1.E-111);
if( !RI.Attach(RInm) ) return(-1);
if( !RA.Attach(RAnm) ) return(-2);
n=RI.GetSize();
RA.SetSize(n);
for(I=0;I<n;I++) { RA[I]=-RI[I]; }
return(n);
}//END CallByCol

In Origin Pro 8.0 the following script

type "----------";
col(1)=round(uniform(33, 123)*100,0);
rslt=CallByCol("Book1_A","Book1_UU");
type UU:$(rslt);

rslt=CallByCol("Book1_A","Book1_B");
type B:$(rslt);

rslt=CallByCol(col(1),col(3));
type col():$(rslt);
type "----------";

col(5)=-1;
col(3)=data(0,PI,PI/33);
col(4)=cos(col(3));
col(5)=sin(col(3));
col(6)=col(4)^2+col(5)*col(5);
if (col(5) == 1 ) {type ---false};
else {type " +++true"};

yields as output:

----------
UU:-2
B:33
col():-1
----------
+++true

And of course, in the second call, Book1B = -Book1_A

In Origin 7.5, the output is:

----------
UU:-2
B:33
col():33
----------
+++true

as it should be.

Is this a feature of Origin 8.0 ?

Regards, Rainer

BTW: ANSII C compatible forward declaration of CallByCol()
returns "unknown function" upon calling - despite 'sucessful' compilation and linkage. ???

Dr. Rainer Facius, German Aerospace Center

Iris_Bai

China
Posts

Posted - 12/04/2009 :  02:04:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

From Origin80, if want to pass the name of origin object to Origin C string argument, for example Column, need to get its real name firstly. That type calling in Origin7.5 is not standard.

So need change
rslt=CallByCol(col(1),col(3));
to:

string str1$ = nameof(col(1))$;
string str2$ = nameof(col(3))$;
rslt = CallByCol(str1$, str2$);


If this change will cause lots of 75 labtalk script not worked, our technical support team can help to modify.
You can send your codes to tech@originlab.com, please remember to attach the address of this post in your email, we will help to correct your codes to follow Origin8 standard and then send back to you.


Iris
Go to Top of Page

drreaf

Germany
45 Posts

Posted - 12/04/2009 :  04:01:05 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Iris,

thank you for your offer to have my O7.5 scripts modified by originlab.

Reading that this usage is no more supported in O8.x is an unpleasant surprise.

Since in O7.5 I used nearly exclusively the col(number) syntax, these modifications would be quite extensive. Doing the changes by automatic string-replacement would be a very dangerous thing to do. Therefore, I prefer to do it by myself with an appropriate utility.

I would like to ask for a further clarification, since I am not at my workplace for some days so that I could check the answer by myself. Instead of the separate assignments to str1$/str2$, I guess I could as well write:

reslt=CallByCol( nameof(col(1))$, nameof(col(2))$ )

Furthermore, I surmise that this syntax would be downward compatible with O7.5 ?

Thanks again, Rainer

Dr. Rainer Facius, German Aerospace Center
Go to Top of Page

Iris_Bai

China
Posts

Posted - 12/07/2009 :  02:17:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

reslt=CallByCol( nameof(col(1))$, nameof(col(2))$ ) this usage is correct, but the result is not right now, this is a bug, we have trackered in #14798 and will fix it in Origin8.1 SR2. But in Origin80, need to use seperate two string variables for now.

Iris
Go to Top of Page

drreaf

Germany
45 Posts

Posted - 12/07/2009 :  04:21:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Iris,

... well, that means quite some hand work instead of automatic replacement, since I assume that SR2 is not yet ready for release soon.

Rainer :-(
Go to Top of Page

greg

USA
1378 Posts

Posted - 03/23/2010 :  4:18:31 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
We have added a System Variable (@UV) to Origin 8.1 SR2 which controls when Origin will 'vectorize' a function, that is when it will auto-index into a vector on both the input and output sides.

Consider this function:

double CubeRoot(double dVal)
{
if(dVal < 0) return -10^(log10(abs(dVal))/3);
else return 10^(log10(dVal)/3);
}

which is defined simply as a double taking a double argument. With vectorization, you can pass a dataset argument and get a dataset in return. After building the above function, run this LabTalk to see the difference:

newbook;
col(1) = data(1,27);
@UV=0;
set col(2) -e 27;
col(2)=cuberoot(col(1));
@UV=1;
col(3)=cuberoot(col(1));

The default value of the @UV System Variable is 1 to allow vectorization.
To run older code where this behavior is not desirable, set the value to 0, as in:

@UV = 0;
run.section(MyOldCode,Main);
@UV = 1;
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