Comments (5)
You are hitting reflection here.... If you use a Clojure type hint then it should solve the issue, e.g.
(.distanceSquared ^AVector sparse-indexed-left ^AVector sparse-indexed-right)
from vectorz.
Definite possibility but I think that is not the case here.
I have:
(set! warn-on-reflection true)
At the top of the file and it compiles with no warnings.
I dove through the code to figure out what is going on and here are the results of the analysis:
First, we are dealing with very sparse vectors, basically 1 out of 100 elements are nonzero. Given that each vector is of len length with num-elems being (* .01 len) nonzero items on average.
The implementation of distance square for AVector is here:
public double distanceSquared(AVector v) {
int len=checkSameLength(v);
double total=0.0;
for (int i=0; i<len; i++) {
double d=unsafeGet(i)-v.unsafeGet(i);
total+=d*d;
}
return total;
}
This has a running time of O(len) where len is the total length of the indexed vectors.
The implementation I attached at the top of the file has a running time on the order of num-elems given that the sparse vector clone, sub, and magnitudeSquared operations are all on the order of O(num-elems).
from vectorz.
OK thanks yes I see what is happening. this implementation should probably be in Vectorz itself rather than on the Clojure side, I'll take a look and insert it in the right place.
Thanks!
from vectorz.
OK I think this is fixed in this commit:
from vectorz.
Yep, verified from this end.
from vectorz.
Related Issues (20)
- Support for long indices HOT 1
- Can't create SparseColumnMatrix HOT 1
- includeIndices causes memory leak when adding many times HOT 4
- Different implementations of innerProduct for row vs column matrices? HOT 2
- Creating sparse matrix in clojure HOT 1
- Slow SparseColumnMatrix innerProduct HOT 5
- Add possibility for sparse default value different than zero HOT 1
- Strange exception with join-along HOT 1
- sparse matrix equality HOT 6
- Will there be future support for single-precision floating point numbers? HOT 1
- Mistake in JoinedArray.get(int x, int y) HOT 2
- How to serialize a mikera.arrayz.INDArray? HOT 2
- Real angles in Vector2 rotateInPlace(), rotate() to copy original HOT 1
- Unable to create NDArray for multidimensional arrays HOT 2
- Equivalent to Numpy amin, argsort? HOT 1
- AVector.angle returns NaN HOT 4
- Negative dimension in NDArray.reshape HOT 1
- `asElementList` on identity matrices stack overflows
- Question about efficiency HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vectorz.