Page 1 of 1

Complex Value types in Javascript and Opaque Actions

PostPosted: Thu Apr 01, 2021 2:50 pm
by kfisher@strattechnologies.com
Hello,

This is my first post. Apologies if I am breaking any guidelines.
I am trying to perform operations on arrays and matrices of complex numbers.
I have been unable to access the javascript math.complex libraries, so I am using CSM Built-in Math instead. Is there a way to include math.complex for javascript?

I have attached an image of an activity diagram which reads a structural feature, typed as Complex and given a default value. I am trying to send that complex value to an opaque action, and use the real() and imag() functions to perform operations on the data within the opaque action, however I get an error "Invalid input parameter in function real" I have the output and input pins typed as Complex.

Any help would be greatly appreciated as I need to perform many operations on arrays and matrices of complex numbers in order to simulate waveforms.

Thanks

Re: Complex Value types in Javascript and Opaque Actions

PostPosted: Tue Apr 13, 2021 9:03 am
by kfisher@strattechnologies.com
I was able to solve the first part of my problem. I had to type the "Opaque Expression" of complex_number as complex. The opaque expression is hidden in the containment tree, but found under the complex_number value type.

I am still wondering if and how I can import javascript libraries into CSM, such as Math.js, so that I can utilize things like math.complex in my javascript opaque expressions.

Thanks