Since you have not mentioned the language of your preference, I am providing the code in C++.
CODE
// C++ program to multiply
// two square matrices.
#include <iostream>
using namespace std;
#define N 4
// This function multiplies
// mat1[][] and mat2[][], and
// stores the result in res[][]
void multiply(int mat1[][N],
int mat2[][N],
int res[][N])
{
int i, j, k;
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
{
res[i][j] = 0;
for (k = 0; k < N; k++)
res[i][j] += mat1[i][k] *
mat2[k][j];
}
}
}
// Driver Code
int main()
{
int i, j;
int res[N][N]; // To store result
int mat1[N][N] = {{0, 0, 0, 0},
{0, 1, 2, 3},
{0, 2, 4, 6},
{0, 3, 6, 9}};
int mat2[N][N] = {{0, 1, 2, 3},
{1, 2, 3, 4},
{2, 3, 4, 5},
{3, 4, 5, 6}};
cout << "Matrix A is \n";
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
cout << mat1[i][j] << " ";
cout << "\n";
}
cout << "\nMatrix B is \n";
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
cout << mat2[i][j] << " ";
cout << "\n";
}
multiply(mat1, mat2, res);
cout << "\nResult matrix is \n";
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
cout << res[i][j] << " ";
cout << "\n";
}
return 0;
}
2)
#include <bits/stdc++.h>
using namespace std;
// maximum size of matrix
#define MAX 4
// maximum number of threads
#define MAX_THREAD 4
int matA[MAX][MAX] = {{0, 0, 0, 0},
{0, 1, 2, 3},
{0, 2, 4, 6},
{0, 3, 6, 9}};
int matB[MAX][MAX] = {{0, 1, 2, 3},
{1, 2, 3, 4},
{2, 3, 4, 5},
{3, 4, 5, 6}};
int matC[MAX][MAX];
int step_i = 0;
void* multi(void* arg)
{
int core = step_i++;
// Each thread computes 1/4th of matrix multiplication
for (int i = core * MAX / 4; i < (core + 1) * MAX / 4; i++)
for (int j = 0; j < MAX; j++)
for (int k = 0; k < MAX; k++)
matC[i][j] += matA[i][k] * matB[k][j];
}
// Driver Code
int main()
{
int i, j;
// Displaying matA
cout << endl
<< "Matrix A" << endl;
for (int i = 0; i < MAX; i++) {
for (int j = 0; j < MAX; j++)
cout << matA[i][j] << " ";
cout << endl;
}
// Displaying matB
cout << endl
<< "Matrix B" << endl;
for (int i = 0; i < MAX; i++) {
for (int j = 0; j < MAX; j++)
cout << matB[i][j] << " ";
cout << endl;
}
// declaring four threads
pthread_t threads[MAX_THREAD];
// Creating four threads, each evaluating its own part
for (int i = 0; i < MAX_THREAD; i++) {
int* p;
pthread_create(&threads[i], NULL, multi, (void*)(p));
}
// joining and waiting for all threads to complete
for (int i = 0; i < MAX_THREAD; i++)
pthread_join(threads[i], NULL);
// Displaying the result matrix
cout << endl
<< "Multiplication of A and B" << endl;
for (int i = 0; i < MAX; i++) {
for (int j = 0; j < MAX; j++)
cout << matC[i][j] << " ";
cout << endl;
}
return 0;
}
Consider the product of two matrices A and B of dimensions 4 x 4 as shown below. 0 1 2 3 11 2 3 4...
Consider the product of two matrices A and B of dimensions 4 x 4 as shown below 100 00 I 1 01 23 I 1 0 2 46 X 0369 1 01 2 3 I | 1 2 3 4 234 5 I 1 3 45 6 I | 14 20 26 32 - 28 40 52 64I 1 42 60 78 96I 1. Write a program to find the product of two matrices. The program should display the two...
7. Consider the following matrices 2 3-1 0 1 A=101-2 3 0 0 0-1 2 4 2 3 -1 B-101-2 0 0-1 2 3 -1 0 c=101-2 3 For each matrix, determine (a) The rank. (b) The number of free variables in the solution to the homogeneous system of equa- tions (c) A basis for the column space d) A basis for the null space for matrices A and HB e) Dimension of the column space (f) Nullity (g) Does...
tut3.1
1. Find the modal matrices M for 1 3 3 5 -1 2 0 1 2 (a) A (b) A (c) A =0 3 0 4 2 3 3 and check by direct matrix multiplication that M 'AM results in the correspond ing spectral matrices A
1. Find the modal matrices M for 1 3 3 5 -1 2 0 1 2 (a) A (b) A (c) A =0 3 0 4 2 3 3 and check by direct...
Add these two matrices Matrix A= 4 1-2 Matrix B= 1 4 1-2 3 11
IN JAVA PLEASE!!! :) Multithreading can help in achieving parallelism in computational problems. This makes the program’s response to generate output faster. It is achieved by delegating independent tasks within the program to separate threads instead of creating a sequential routine. Consider the following sample double array: 3 11 5 19 1 8 4 16 7 18 17 6 3 23 9 If the problem is to display all the row-sums and all the column-sums, a sequential program would use...
Question 2 Given matrices A and B shown below, find (-3)A+ (4)B CONTENT FEE 4 2 4 A-1-3 4-51 and B=|-2 [0-2-4 Give your answer as a matrix using the matrix tool. ide your answer below
06) Write a C program to perform matrix operations based of threads. The program accepts from the user a positive integer N. A menu is given to the user: 1. generate matrices: generates three NxN matrices A, B, C with random integer numbers between 0 and 9 2. add: matrix D- A+B+C 3. subtract: matrix D A-B-C 4. display matrices: A, B, C, D 5. display count of result values more than 8. 6. exit: terminate the program When the...
3. Write a complete assembly language program to read two matrices (2-dim arrays) A and B and display the resulting matrix C, which is the sum of A and B. Procedures must be used to organize the code.
only answer
and thank you
السوال 1 The product of matrices [28]+[043] is: [-4 14 lo 3 4 141 1-3] 1-4 -14 2. Jul The statem +2y=1 has infinity solutions if +1V- =0 a=2 a = 0 حالة امام الامام The matrix A has no inverse if x equal to x = 4 x = 16 السوال 4 If A and B are 3*3 matrices, and if det(A)=2, det (B)=3 then det (48) = 16