OjAlgo如何映射/更新PrimitiveDenseStore中的所有值?

时间:2017-06-06 19:19:31

标签: java matrix ojalgo

假设我有一个2x2矩阵作为PrimitiveDenseStore

std::vector<std::unique_ptr<T>>

是否有基于给定的匿名函数(如

)映射所有这些值
pstore = [ 1 2 
           3 4 ]

结果是

pstore.map(x -> x * x)

2 个答案:

答案 0 :(得分:1)

好吧我对java的UnaryOperator感到困惑ojAlgo期待自己的功能界面PrimitiveFunction.Unary

PrimitiveFunction.Unary square = arg -> arg * arg;
pstore.modifyAll(square);

答案 1 :(得分:0)

至少有3种选择可供您进行&#34;调查&#34;:

pstore.loopAll(...);
pstore.modifyAll(...);
pstore.operateOnAll(...);

和/或您可以查看这些问题的答案:

OjAlgo : Is there a way to add/subtract a double from all elements of a PrimitiveDenseStore in ojAlgo?

Elementwise multiplication two matrices or PrimitiveDenseStores in ojAlgo