identitymatrix.java~1~
来自「一个一元曲线多项式数值演示例子」· JAVA~1~ 代码 · 共 27 行
JAVA~1~
27 行
package numbercruncher.matrix;
public class IdentityMatrix extends SquareMatrix
{
/**
* Constructor.
* @param n the number of rows == the number of columns
*/
public IdentityMatrix(int n)
{
super(n);
for (int i = 0; i < n; ++i) values[i][i] = 1;
}
/**
* Convert a square matrix into an identity matrix.
* @param sm the square matrix to convert
*/
public static void convert(SquareMatrix sm)
{
for (int r = 0; r < sm.nRows; ++r) {
for (int c = 0; c < sm.nCols; ++c) {
sm.values[r][c] = (r == c) ? 1 : 0;
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?