Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Expression Support #46

Open
Roger-luo opened this issue Jan 17, 2016 · 3 comments
Open

Basic Expression Support #46

Roger-luo opened this issue Jan 17, 2016 · 3 comments

Comments

@Roger-luo
Copy link

Will QuArray support storing base's expression? or a new subtype of QuArray?

my problem is,for example:

to store a specific state like

\frac{1}{\sqrt{2}}(sin(\frac{\pi}{a}x)+sin(\frac{2\pi}{a}x))

the QuArray type can store it like this at present

a = QuArray([x->1/sqrt(2)*sin(2/a)*sin(1*pi/a*x),x->1/sqrt(2)*sin(2/a)*sin(2*pi/a*x)])

however I hope the coeffs can be isolated from the base' expressions

@acroy
Copy link
Contributor

acroy commented Jan 18, 2016

I think right now this is not easily possible. Note that QuArrays are really meant to be containers for the coefficients. The information about the basis would be stored in a separate type, but there isn't much support yet. Basically, I could imagine to have a basis type, which stores expressions for the basis functions and roughly does what you want. Isolating coefficients from an expression might be tricky to do in general, but maybe one could have some convention and then use macros to extract coefficients and basis-function expressions. All of this would be a cool feature of course!

Having said this, I think you might want to have a look at @jrevels QuDirac package. He might also have an idea regarding the basis types ...

@Roger-luo
Copy link
Author

And about storing a state with expression of basis.what about a subtype of QuArray that have a field to store Functions. Cause not only expressions should be store. Sometimes a variable points to a solver with specific parameters

#pretend this to be some kind of numerical solver
function state(a,b,c)
 return sin(a*b*c)
end

and to store a state like

1/sqrt(2)*state(1,2,3)+1/sqrt(2)*state(2,3,4)

a type that can really stores a function is needed.And specific expressions can also be stored as function,for example

function state_of_an_oscillator(n)
        return supose_this_is_an_expression()
end

I wrote a simple one in https://github.com/Roger-luo/AdiaRoll.jl/blob/master/src/base.jl

@jrevels
Copy link
Contributor

jrevels commented Jan 18, 2016

You can do this with QuDirac.jl, but that package only works with Julia v0.3 and won't be updated until Julia v0.5 releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants