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
 Problem in complex number calculation

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
modimh Posted - 07/01/2002 : 03:19:07 AM
I have written a programme using OriginC. I need to calculate exponential value of complex numbers. The exponential function available in complex.h file didnot give me correct value of my complex numbers. for example my OriginC function contains following:


complex a,b;
a=1+2i;
b=exp(a);
printf("%e",cabs(b));

here irrespective of value 'a' the output remains same. Please help me
4   L A T E S T    R E P L I E S    (Newest First)
easwar Posted - 07/04/2002 : 2:21:20 PM
quote:

...If there is another better way to do it please suggest.
...My OriginC function is working well. I want to include it in non-linear fitting functions list.



Hello,

We need to fix the problem with product of complex and real vectors. The workaround you are using is good.

As for using your Origin C function to perform fitting, you can look at the sample project:
..\Sample Projects\Programming\NLSF User-defined Function\AsymGauss.opj
to see how you can define and add a new fitting function that uses an Origin C function.

You can also type the Origin C code right inside the function. Please review the following sample project for an example:
..\Sample Projects\Data Analysis\Curve Fitting\NLSF User Def Func.opj

Easwar
OriginLab.
modimh Posted - 07/04/2002 : 08:50:13 AM
The two vector defined M[j], N[j] is of type complex. And other d[j] is of type double. I had typed but surprisingly it is not being shown on screen

vector M(10), N(10);//complex type
vector d(10);// double type


M.H.Modi


modimh Posted - 07/04/2002 : 04:20:47 AM
Hi Dr. Easwar
Thank you very much for reply. I have analysed the problen in my programme. Actually when i was multiplying complex defined array with double defined array and inputting this to exponential function than the output was remainning same=(1+0i) irrespective of input values. I have used following scheme to solve the problem

vector M(10), N(10);
vector d(10);

N[j]=exp(M[j]*d[j]); //this way the result was remainning same irrespective of input parameters values.
So I have defined another temperary variable
and stored d[j] in that i.e.

double temp;
temp=d[j];
now
N[j]=exp(M[j]*temp);

This way the value of N[j] is changing as input values changing. If there is another better way to do it please suggest.
My OriginC function is working well. I want to include it in non-linear fitting functions list. Can I do it Please suggest.
Regards
M.H.Modi
quote:

Hi,

For the sequence of operations you are doing, the result should depend only on the real part of a.

a=p+iq
b=exp(p+iq) = exp(p)* exp(iq)
conjgate of b, b* = exp(p) * exp(-iq)
cabs(b) = sqrt(b x b*) = sqrt(exp(2p)) = exp(p)


Easwar
OriginLab.


Edited by - easwar on 07/01/2002 09:48:17

easwar Posted - 07/01/2002 : 09:43:02 AM
Hi,

For the sequence of operations you are doing, the result should depend only on the real part of a.

a=p+iq
b=exp(p+iq) = exp(p)* exp(iq)
conjgate of b, b* = exp(p) * exp(-iq)
cabs(b) = sqrt(b x b*) = sqrt(exp(2p)) = exp(p)


Easwar
OriginLab.


Edited by - easwar on 07/01/2002 09:48:17

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