Reputation: 8058
Say I have an 2x2 matrix as PrimitiveDenseStore
pstore = [ 1 2
3 4 ]
Is there anyway to map all these values based on given anonymous function like
pstore.map(x -> x * x)
So the result is
pstore = [ 1 4
9 16 ]
Upvotes: 1
Views: 209
Reputation: 8058
Okay I was confused with java's UnaryOperator
turns out ojAlgo expects its own Functional Interface PrimitiveFunction.Unary
PrimitiveFunction.Unary square = arg -> arg * arg;
pstore.modifyAll(square);
Upvotes: 1
Reputation: 1320
There are at least 3 alternatives for you to "investigate":
pstore.loopAll(...);
pstore.modifyAll(...);
pstore.operateOnAll(...);
and/or you could have a look at the answers to these questions:
Elementwise multiplication two matrices or PrimitiveDenseStores in ojAlgo
Upvotes: 0