Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MatrixMultiply
- {
- public int[,] MatrixMultEasy(int[,] left, int[,] right)
- {
- int[,]Matrix = new int[left.GetLength(0), right.GetLength(1)];
- for (int i = 0; i < left.GetLength(0); i++)
- {
- for (int j = 0; j < right.GetLength(1); j++)
- {
- int sum = 0;
- for (int k = 0; k < right.GetLength(0); k++)
- {
- sum += left[i, k] * left[k, j];
- }
- Matrix[i, j] = sum;
- }
- }
- return (Matrix);
- }
- public bool CheckOnCorrect(int[,] left, int[,] right)
- {
- if ((left != null) && (right != null))
- {
- if (left.GetLength(1) != right.GetLength(0))
- {
- return (false);
- }
- else
- {
- return (true);
- }
- }
- else
- {
- return (false);
- }
- }
- }
- class MatrixSum
- {
- public int[,] Do(int[,] left, int[,] right)
- {
- for (int i = 0; i < left.GetLength(0); i++)
- {
- for (int j = 0; j < right.GetLength(1); j++)
- {
- left[i, j] += right[i, j];
- }
- }
- return (left);
- }
- public bool CheckOnCorrect(int[,] left, int[,] right)
- {
- if ((left != null)&&(right != null))
- {
- if ((left.GetLength(0) == right.GetLength(0)) && (left.GetLength(1) == right.GetLength(1)))
- {
- return (true);
- }
- else
- {
- return (false);
- }
- }
- else
- {
- return (false);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement