Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Matrix MultiplyAsynchronous(Matrix matrix1, Matrix matrix2)
- {
- if (matrix1.ColumnCount != matrix2.RowCount)
- throw new ArgumentException(Resources.ErrorMessages.ArgumentMatricesIncompatible);
- Matrix result = new Matrix(matrix1.RowCount, matrix2.ColumnCount);
- double[] vector = matrix2.GetColumn(0).ToArray();
- double[] row = matrix1.GetRow(asynchronousStep).ToArray();
- if (asynchronousStep == 0)
- {
- for (int index = 0; index < 3; index++)
- {
- result._matrix[0] += row[index] * vector[index];
- }
- result._matrix[1] = vector[1];
- result._matrix[2] = vector[2];
- }
- else if (asynchronousStep == 1)
- {
- for (int index = 0; index < 3; index++)
- {
- result._matrix[1] += row[index] * vector[index];
- }
- result._matrix[0] = vector[0];
- result._matrix[2] = vector[2];
- }
- else if (asynchronousStep == 2)
- {
- for (int index = 0; index < 3; index++)
- {
- result._matrix[2] += row[index] * vector[index];
- }
- result._matrix[0] = vector[0];
- result._matrix[1] = vector[1];
- }
- asynchronousStep++;
- if(asynchronousStep > 2)
- {
- asynchronousStep = 0;
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement