카테고리 없음

[씨#] 행렬 다중 파일 화 2x2 2x1 C #

필살기쓰세요 2021. 2. 10. 12:11

.NET에는 이미 이에 대한 라이브러리가 있다고 생각합니다. 여기에서 읽으십시오 : https://msdn.microsoft.com/en-us/library/system.windows.media.matrix.multiply(v=vs.110).aspx

기본적으로 예는 다음과 같습니다.

private void multiplicationExample()
{

    Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
        Matrix matrix2 = new Matrix(2, 4, 6, 8, 10, 12);
        
            // matrixResult is equal to (70,100,150,220,240,352) 
                Matrix matrixResult = Matrix.Multiply(matrix1, matrix2);
                
                    // matrixResult2 is also
                        // equal to (70,100,150,220,240,352) 
                            Matrix matrixResult2 = matrix1 * matrix2;
                            
                            
                            }
                            
-------------------

math.net을 사용해보십시오 . 예를 들면 다음과 같습니다.

var matrixA = DenseMatrix.OfArray(new[,] { { 1.0, 2.0 }, { 4.0, 5.0 } });
var matrixB = DenseMatrix.OfArray(new[,] { { 1.0 }, { 2.0 } });

var result = matrixA * matrixB;
Console.WriteLine(result);

이 .NET Fiddle보기



출처
https://stackoverflow.com/questions/39930072