sebiniemann / ArmadilloJava

Pure Java-based linear algebra library
armadillojava.org
8 stars 8 forks source link

For-each for Mat not working anymore #108

Closed wlfbck closed 5 years ago

wlfbck commented 10 years ago

Not sure if it was intentionally removed, but the current version is missing a feature, this worked before. for (double val : mat) shows the following error: "for-each not applicable to expression type" required: array or java.langIterable found: Mat

sebiniemann commented 10 years ago

This feature was previously removed because Java supports range-based loops only for objects, not primitive types, impacting the performance by several magnitudes as autoboxing and unboxing is required for this to work.

But we could easily reimplement this feature.

wlfbck commented 10 years ago

I guess it would be handy, atleast its less then two nested for loops :P

sebiniemann commented 10 years ago

Are you assuming to use two nested loops for iterating over all elements?

I would recommend to implement this as followed:

Mat example = new Mat(4, 4, Fill.RANDU); for (into n = 0; n < example.n_elem; n++) { System.out.println(example.at(n)); }

wlfbck commented 10 years ago

Interesting, didn't see the Mat.at()-method.