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

Support evaluating Vector expressions of arbitrary length #3

Open
almstrand opened this issue Jun 12, 2015 · 2 comments
Open

Support evaluating Vector expressions of arbitrary length #3

almstrand opened this issue Jun 12, 2015 · 2 comments
Labels
enhancement Indicates new feature requests

Comments

@almstrand
Copy link

Are there plans to support evaluating Vector expressions of arbitrary length?

Calling evaluate in the following example ...

ContextModel cm = new ContextModel();

Expression vector1 = new Vector([new Number(1), new Number(2), new Number(3), new Number(4), new Number(5)]);
Expression vector2 = new Vector([new Number(1), new Number(2), new Number(3), new Number(4), new Number(5)]);

Expression e = vector1 + vector2;

print(e.evaluate(EvaluationType.VECTOR, cm));

... causes UnimplementedError to be thrown:

Exception: UnimplementedError: Vector of arbitrary length (> 4) are not supported yet.
  Vector.evaluate   
  Plus.evaluate 
  ...

The expected output is "2.0,4.0,6.0,8.0,10.0". It would be great if this limit can be removed.

It seems the current implementation is 99% there. Perhaps classes Vector2, Vector3, and Vector4 can be generalized into a new class that constructs a vector of arbitrary size?

@fkleon
Copy link
Owner

fkleon commented Jun 12, 2015

Hi, thanks for your report!

Currently math_expressions is using vector_math under the hood for its vector representations - which is unfortunately only supporting vectors up to 4 elements.

It shouldn't be too hard to introduce a generalisation though - at least if performance is not crucial - vector_math even comes with an abstract base class backed by a simple list.

Handling of vectors in math_expressions is still a bit rough and a lot of functions don't work on vectors yet. I might be able to flesh out some basic implementation for vectors of arbitrary length relatively easily. In the meantime, pull requests are always welcome :)

@almstrand
Copy link
Author

Thanks for the quick response and feedback. In thinking more about the problem it seems a preferred solution may be for the vector_math package to support n-dimensional vectors.

I filed an issue with the project to see how the community feels about supporting that.

As n-dimensional vectors have many applications, it would be a shame for this restriction to become a cause for fragmentation at the expense of the otherwise excellent vector_math package, and a cause for mostly redundant vector packages to appear on pub.dartlang.org.

@fkleon fkleon added the enhancement Indicates new feature requests label Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests
Projects
None yet
Development

No branches or pull requests

2 participants