3

Is there a Java array library which supports slicing? I just need regular n x n' x n'' x ... arrays and either taking one slice from given dimension or whole dimension (i.e. no need for ranges).

Notes (read replies to potential comments):

  • I know that regular Java arrays are not supporting it and I'm not willing to write my own slicing library.
  • Using Collection (suggested in comment to other question) based shifts the problem
  • Using System.arraycopy does not help in high dimension as it does not lower the nesting of loops significantly
  • This is (sort of - long story) numerical problem so OO approach for inner code is not necessary the best one - the most usable abstraction boils down to slicing anyway
  • I would prefer R/W view from slice (if it will only be R/O copy I won't complain though)

EDIT: Unfortunaly I need to store objects inside array - not only double's.

2
  • maybe you are using the wrong tool(java) for the job? Alternatively, would a map with each dimension as a key work? Commented Feb 16, 2013 at 10:55
  • @drone.ah: It's long story but based on description it is what I would say as well. Commented Feb 16, 2013 at 15:29

1 Answer 1

5

Vectorz is a vector/matrix library supports slicing and is a good choice if you are doing numerical work with arrays of double values. It is specifically designed for vector/matrix maths in 3D modelling, gaining, simulation or machine learning contexts.

Advantages:

  • Very fast (everything backed by primitive doubles and double[] arrays)
  • 100% Pure Java
  • Supports arbitrary slicing and dicing, mostly as O(1) operations (i.e. no data copying required)
  • Slices are fully read/write enabled, i.e. you can use them to modify the original structures
  • You can also join vectors together, take subvector views etc.
  • Specialised classes for numerical work, e.g. diagonal matrices etc.

It currently supports 0, 1 and 2 dimensional arrays, higher dimensional arrays are planned but not yet implemented.

Sign up to request clarification or add additional context in comments.

2 Comments

+1. Looks nice however I need something to store an object inside array - not only double (I admit - I might mislead by using 'numerical' inside description).
Nice library. It seems to be modeled after numpy arrays. V fast, but does not have many features.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.