Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Complex numbers in excel

I do a call to a sub akoef in the code beneath. It works fine in the
non-complex case that I have coded:

first, the call in main program:

'''''''''''''''''''''''''''''''

Call AKOEF(OM, DELT, NAX, G, AKD, a, B)

''''''''''''''''''''''''''''''
here is the called sub - the complex suggestions are in comments:

Sub AKOEF(OM, DELT, NAX, G, AKD, a, B)

i = 1 ' should be -1 for complex
i = Sqr(i) ' should be imsqrt for complex
sa = 0
AKD(NAX) = sa
ARG = Sqr(1 / a) * (-i * OM - 0.5 * OM * (B / a)) * DELT * NAX
s1 = G(NAX) * Exp(ARG) ' exp should be imexp for complex
NA = NAX - 1
For jj = 1 To NA
j = NAX - jj
AKs = AKD(j) * AKD(j)
ARG = Sqr(1 / a) * (i * OM - 0.5 * OM * (B / a)) * DELT * j
s2 = G(j) * Exp(ARG) * (1 - AKS) ' exp should be imexp for complex

sa = 0.5 * (s1 + s2) * DELT + sa
AKD(j) = Exp(-ARG) * sa 'exp should be imexp for complex
s1 = s2
Next jj
End Sub
-----------------------------------------

in FORTRAN the complex case is very simple. I just declare the complex
variables in akoef with a type command like this:

TYPE COMPLEX AKD,AK,AKS,I,CEXP,CSQRT,ARG,S1,S2,SA

I exchange the real function with complex functions. Complex fortran is a
bit different from excel, but the idea is the same.

and the call will return a complex variable AKD.

....so this is no problem..
.... there must be a way to do it simple also in excel. Anyone with experience?
--
With regards Knut S
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default Complex numbers in excel

Open VBA editor and type COMPLEX in the search box
Look at the method called Complex
You should not try to use
i=-1; i=SQR(i)
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"knutso" wrote in message
...
I do a call to a sub akoef in the code beneath. It works fine in the
non-complex case that I have coded:

first, the call in main program:

'''''''''''''''''''''''''''''''

Call AKOEF(OM, DELT, NAX, G, AKD, a, B)

''''''''''''''''''''''''''''''
here is the called sub - the complex suggestions are in comments:

Sub AKOEF(OM, DELT, NAX, G, AKD, a, B)

i = 1 ' should be -1 for complex
i = Sqr(i) ' should be imsqrt for complex
sa = 0
AKD(NAX) = sa
ARG = Sqr(1 / a) * (-i * OM - 0.5 * OM * (B / a)) * DELT * NAX
s1 = G(NAX) * Exp(ARG) ' exp should be imexp for complex
NA = NAX - 1
For jj = 1 To NA
j = NAX - jj
AKs = AKD(j) * AKD(j)
ARG = Sqr(1 / a) * (i * OM - 0.5 * OM * (B / a)) * DELT * j
s2 = G(j) * Exp(ARG) * (1 - AKS) ' exp should be imexp for complex

sa = 0.5 * (s1 + s2) * DELT + sa
AKD(j) = Exp(-ARG) * sa 'exp should be imexp for complex
s1 = s2
Next jj
End Sub
-----------------------------------------

in FORTRAN the complex case is very simple. I just declare the complex
variables in akoef with a type command like this:

TYPE COMPLEX AKD,AK,AKS,I,CEXP,CSQRT,ARG,S1,S2,SA

I exchange the real function with complex functions. Complex fortran is a
bit different from excel, but the idea is the same.

and the call will return a complex variable AKD.

...so this is no problem..
... there must be a way to do it simple also in excel. Anyone with
experience?
--
With regards Knut S



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i write complex numbers inside excel cels? STINGER Excel Discussion (Misc queries) 3 October 21st 07 06:44 PM
import complex numbers to excel wabodie Excel Worksheet Functions 0 September 9th 06 07:31 PM
How do I set up Excel to handle complex (& imaginary) numbers? Peter Thompson Excel Worksheet Functions 2 September 1st 06 02:58 PM
Complex Numbers in Excel? Oliver Gräser Excel Programming 1 June 19th 06 01:40 PM
Complex numbers in VBA (Excel( levent Excel Programming 2 July 22nd 04 08:58 PM


All times are GMT +1. The time now is 06:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"