【问题标题】:Get a Matrix from another Matrix从另一个矩阵获取一个矩阵
【发布时间】:2015-05-03 18:15:34
【问题描述】:

各位,我正在开发一个结构分析程序,但遇到了一个问题,我有一些问题需要解决。基本上,我有一个方程组,我只需要解决其中的一些。 我需要解决的问题取决于一个布尔数组,如果我这样做,则为 true,如果我不这样做,则为 false。这样,在数组的第 n 个元素中具有真值意味着我必须求解第 n 个方程,因此意味着我必须得到方程组矩阵的 nxn 元素。 各位大侠有什么见解吗?

【问题讨论】:

  • 您必须解决整个系统,然后从解决方案向量中获得所需的值。没有办法只求解一个方程。
  • 除非忽略整个方程会放松对系统的约束,这可能会增加解空间的维数……举个例子就好了。
  • 我想我没有正确表达自己。我只需要求解给定的方程,因为其他方程已经通过轮廓条件求解。因此,我所要做的就是从一个更大的方阵中得到一个方阵,我猜。

标签: java arrays matrix boolean


【解决方案1】:

所以,这就是我想出的:

//Firstly, define the size of the subsystem:
    int size = 0;
    for(int i = 0; i < TrueorFalseMatrix.m; i++) {
        if(TrueorFalseMatrix.data[i][0] != 0) 
            size+= 1;
    }
    //Then we can assign the size values to the Matrix of the subsystem
    System_A = Matrix.matrizEmpty(size,size);
    System_B = Matriz.matrizEmpty(size, 1);
    //This array will store the coordinates of the coefficients that
    //will be used
    int[] Coordinates = new int[size];
    //We store these coordinates in the array
    int count = 0;
    for(int i = 0; i < TrueorFalseMatrix.m; i++) {
        if(TrueorFalseMatrix.data[i][0] != 0) {
            Dtrue[count] = i;
            count++;
        }
    }
    //We can now assign values to our system Matrix
    for(int i = 0; i < size; i++) {
        for(int j = 0; j < size; j++) {
            System_A.data[i][j] = SourceMatrix.data[Dtrue[i]][Dtrue[j]];
        }
        System_B.data[i][0] = SourceResultVector.data[Dtrue[i]][0]
    }
    //Results
    double[] Results = System.solve(System_A,System_B);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多