我解决了以下等式:
要解决它,我想使用矩阵指数:
我想了3种方法:
你能帮我找到我应该使用的最好的方法/类吗?谢谢你
注意:这个问题是“跟进问题”:initial question
编辑 : 这就是我现在尝试过的,这是最好的方法吗?:
import static org.ojalgo.function.PrimitiveFunction.EXP;
public class SolveDifferentialEquationTest
{
private static final PhysicalStore.Factory<Double, PrimitiveDenseStore> matrixFactory = PrimitiveDenseStore.FACTORY;
public static void main(String[] args)
{
SparseStore<Double> matrix;
final PhysicalStore<Double> diagMatrix;
final PhysicalStore<Double> eigenVectorMatrix;
final PhysicalStore<Double> inverseEigenVectorMatrix;
final Eigenvalue<Double> eigenvalue;
final int time = 100;
PhysicalStore<Double> initialVector;
final PhysicalStore<Double> finalVector;
int dim = 2000;
matrix = SparseStore.PRIMITIVE.make(dim, dim);
initialVector = matrixFactory.makeZero(dim,1);
// fill matrix and initialVector
//...
//Decompose matrix
eigenvalue = Eigenvalue.PRIMITIVE.make(matrix);
eigenvalue.decompose(matrix);
diagMatrix = eigenvalue.getD().copy();
eigenVectorMatrix = eigenvalue.getV().copy();
InverterTask<Double> inverter = InverterTask.PRIMITIVE.make(eigenVectorMatrix);
try {
inverseEigenVectorMatrix = inverter.invert(eigenVectorMatrix).copy();
} catch (RecoverableCondition e) {
throw new RuntimeException(e);
}
// Construct exp(Dt)
diagMatrix.multiply(time);
diagMatrix.modifyDiagonal(EXP);
// Compute
finalVector = inverseEigenVectorMatrix.multiply(diagMatrix)
.multiply(eigenVectorMatrix)
.multiply(initialVector)
.copy();
}
}