Complex Variables
Complex Variables
(OP)
Does anyone have code, or know of public domain code, that will allow use of complex variables via VBA?
I can also do it with the analysis toolpak, but am looking for a pure VBA solution.
I can also do it with the analysis toolpak, but am looking for a pure VBA solution.
RE: Complex Variables
I can understand why you want to avoid the tool-pak – tough to set up and tough to share spreadsheet.
I think Alg-lib will do what you want.
Alglib is a free math package has a complex data type and set of complex arithmetic. The specific module that contains all that is called AP.BAS. I think it would be fairly straightforward to load that although I remember when I started using their functions it took awhile to figure out which modules were needed. The advantage is there is a large library of other math functions and routines you may be interested in. See Doug / IDS' page or posts for more info on Alglib.
It is not that hard to program the basic complex operations in vba from scratch either.
=====================================
(2B)+(2B)' ?
RE: Complex Variables
http
If you don't need to use the routines as User Defined Functions in the spreadsheet you can just import the AlgLib ap.bas module into a VBA module and call them direct using the Complex data type where required.
Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/
RE: Complex Variables
For example in you Sheet1 if I highlight 2 cells and enter
=AL_Conj(AL_C_add($B$5:$C$5,$B$6:$C$6))
followed by ctrl-shift-enter,
then I get #Value
I think the function Vara2Complex is not equipped to react properly when the argument passed into it already datatype complex.
=====================================
(2B)+(2B)' ?
RE: Complex Variables
=====================================
(2B)+(2B)' ?
RE: Complex Variables
h
Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/
RE: Complex Variables
Also for the benefit of the forum, the link you posted above goes to an editing page which is not directly accesible without a username/password. The link should be:
http://new
=====================================
(2B)+(2B)' ?
RE: Complex Variables
The blog download link just links to the address I gave in my previous post here, so I'm not sure why it asks you for a password from one but not the other.
Anyway, let me know if you still have a problem.
Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/
RE: Complex Variables
The link that doesn't work is the one posted 10 Aug 10 22:06 ... it has "edit" and "admin" in the address so I assume it is limited to people with access to edit the page. But I found it by searching "complex" at your main page.
On your page you said "The use of strings to represent complex numbers seems to me to be cumbersome and inefficient, and for Excel versions before 2007 it requires the installation of the Analysis Tool Pack."
I agree and have expressed similar sentiment. But one thing occurs to me - it is a little easier to manage formulas treating complex numbers as one cell than 2 cells, so I can see why they made that decision.... but not a big deal either way.
I have a spreadsheet done with tool-pak that I'd like to share in a format that does not require tool-pak installation, so this will be useful.
=====================================
(2B)+(2B)' ?
RE: Complex Variables
Ah, yes that a Wordpress edit page.
Don't know why I posted that one.
Glad it's working now anyway.
Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/