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

WISH: implement basic actions on VECTOR datatype #2355

Open
Oldes opened this issue Jan 23, 2019 · 5 comments
Open

WISH: implement basic actions on VECTOR datatype #2355

Oldes opened this issue Jan 23, 2019 · 5 comments

Comments

@Oldes
Copy link

Oldes commented Jan 23, 2019

While vector is nice for compact storing big arrays in memory, its usage is very limited so far, as there are almost no actions implemented yet.
Like:

>> points * 10
** Script error: cannot use multiply on vector! value
** Where: *
** Near: * 10
@Oldes
Copy link
Author

Oldes commented Jan 23, 2019

It is already available in Red:

>> o/points
== make vector! [375.0 128.0 234.0 269.0 383.0 397.0 398.0 103.0 377.0 346.0 262.0 304.0 388.0...
>> o/points * 10
== make vector! [3750.0 1280.0 2340.0 2690.0 3830.0 3970.0 3980.0 1030.0 3770.0 3460.0 2620.0 ...

@giuliolunati
Copy link

giuliolunati commented Jan 23, 2019

I'm strongly interested in that!
At least vector + vector and vector * scalar should be implemented.
And then I wish vector * vector as convolution product.

Oldes added a commit to Oldes/Rebol3 that referenced this issue Jan 23, 2019
Oldes added a commit to Oldes/Rebol3 that referenced this issue Jan 23, 2019
@Oldes
Copy link
Author

Oldes commented Jan 23, 2019

@giuliolunati any proposal how could work vector + vector if the differ in size?
Like in Red where it creates a new vector with the shortest length?

>> v1: make vector! [2 3 4 5]
== make vector! [2 3 4 5]
>> v2: make vector! [10 10]
== make vector! [10 10]
>> v1 + v2
== make vector! [12 13]

For me above commited changes are enough for my current needs.
(actually I needed just vector * number)

@giuliolunati
Copy link

giuliolunati commented Jan 24, 2019

@Oldes I prefer thinking at absent entries as being zero, so for me should be v1 + v2 => [12 13 4 5] Then one can truncate if wants shortest length. (The idea is: don't lose information)

@hostilefork
Copy link
Member

There are some deep questions about VECTOR! to be answered, Red has kept this issue open for a long time, and has no resolution:

red/red#2216

When it comes to math, I think that integers are a good place to start. And with cryptocurrency on the rise, maybe integers that don't fit in 32/64 bit are where to begin that thinking.

I have some starting suggestions here:

https://forum.rebol.info/t/planning-ahead-for-bignum-arithmetic/623

Whatever I think about VECTOR!, the INTEGER! behavior needs to be sorted before Beta/One. Which may hold implications for VECTOR!, depending on the model of what vectors are decided to be.

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

No branches or pull requests

3 participants