6.18.1
Consider the sparse matrix X below and write C code that would store this code in Yale Sparse Matrix Format.
Row 1 [1, 2, 0, 0, 0, 0]
Row 2 [0, 0, 1, 1, 0, 0]
Row 3 [0, 0, 0, 0, 9, 0]
Row 4 [2, 0, 0, 0, 0, 2]
Row 5 [0, 0, 3, 3, 0, 7]
Row 6 [1, 3, 0, 0, 0, 1]
6.18.2
In terms of storage space, assuming that each element in matrix X is single-precision floating point, compute the amount of storage used to store the matrix above in Yale Sparse Matrix Format.
//Include necessary header files
#include <stdio.h>
int main()
{
//Define the sparse matrix X
int X[6][6] = {1, 2, 0, 0, 0, 0,
0, 0, 1, 1, 0, 0,
0, 0, 0, 0, 9, 0,
2, 0, 0, 0, 0, 2,
0, 0, 3, 3, 0, 7,
1, 3, 0, 0, 0, 1};
int A[6*6];
int IA[6];
int JA[6*6];
//Display the matrix in sparse atrix format
printf("Sparse Matrix X");
for(int i=0; i<6; i++)
{
printf(" ");
for(int j=0; j<6; j++)
printf("%d ", X[i][j]);
}
//Read all non zero elements of matrix X and store in array A
int k = 0, l = 0;
for(int i=0; i<6; i++)
{
//IA array represents the matrix X into row splits
IA[l++] = k;
for(int j=0; j<6; j++)
if(X[i][j] != 0)
{
//Store the element in A and then increment the index k
A[k] = X[i][j];
//Store the column index in array JA
JA[k++] = j;
}
}
printf(" Yale Sparse Matrix Format A = ");
for(int i=0; i<k; i++)
printf("%d ", A[i]);
printf(" IA = ");
for(int i=0; i<l; i++)
printf("%d ", IA[i]);
printf(" JA = ");
for(int i=0; i<k; i++)
printf("%d ", JA[i]);
return 0;
}
Screenshot of Code Screen:


Screenshot of Output:

6.18.1 Consider the sparse matrix X below and write C code that would store this code...
C++ Program To demonstrate ability to write sparse matrix operations. Write a C++ class to create 2D sparse matrices, sum them, and transpose them. You don't have to use operator overloading in this program. Each matrix should be shown in sparse format (which shown only non-zero items). This program will be a command line-based program. Do not interact with user with a menu. Instead, user will use "command language" (aka command entry) as detailed below. Your program will keep at...
Given the following code sequence calculating a matrix norm. double c[96], a[96][96]; for (i=0; i<95; i=++ ) { c[i] = c[i] + a[i][i]*a[i][i+1]; } with a and c being arrays of double precision floating point numbers with each element being 8 bytes. No element of a or c is in the cache before executing this code. Please assume row-major ordering. Assuming that the cache is large enough to hold both a and c, and has a cache block size of...
Consider a C function negMat(), that negates each element of a K x K matrix y[][], and stores each result into the matrix x[][] : void negMat(float *x, float *y, int K) { int i, j; for (i=0; i<K; i++) { for (j=0; j<K; j++) { x[i * K + j] = - y[i * K + j]; } } } negMat() runs on the CPU (obviously), and x[][]and y[][] are stored in row-major order. Write a CUDA kernel negMatGPU(),...
answer please!
WRITE YOUR ANSWERS IN THE PROVIDED SPACE. Below are the two standard floating-point formats. - 32 bits SE Sign Odenotes I denotes - 23 hits o mai CRC22 exponent (a) Single precision III II-bence.2023 ponce (b) Double precision a) Represent -6.375 in double floating point format. b) What number is represented by the single precision floating point format: 1-10000000-0011000...00
Write a program that reads a matrix from the keyboard and displays the summations of all its rows on the screen. The size of matrix (i.e. the number of rows and columns) as well as its elements are read from the keyboard. A sample execution of this program is illustrated below: Enter the number of rows of the matrix: 3 Enter the number of columns of the matrix: 4 Enter the element at row 1 and chd umn 1: 1...
1. Write a MATLAB function that takes a matrix, a row number and
a scalar as
arguments and multiplies each element of the row of the matrix by
the scalar returning the
updated matrix.
2. Write a MATLAB function that takes a matrix, two row numbers and
a scalar as
arguments and returns a matrix with a linear combination of the
rows. For example, if the rows
passed to the function were i and j and the scalar was m,...
write an OpenMP program to to optimize matrix multiplication (matmul) code to run fast on a single processor core We consider a special case of matmul: C := C + A*B where A, B, and C are n x n matrices. This can be performed using 2n3 floating point operations (n3 adds, n3 multiplies), as in the following pseudocode: for i = 1 to n for j = 1 to n for k = 1 to n C(i,j) = C(i,j)...
I need help with parts c and d of this question. Some concept
clarification would be great.
3. Consider the following matrix A= 3 6 (a) Compute AAT and its eigenvalues and unit eigenvectors. (b) Find the SVD by computing the matrices U, V, Σ (c) From the u's and v's in (b), write down orthonormal bases for all four fundamental subspaces (i.e., row space, column space, null space, left null space) of the matrix A. (d) Compute the pseudoinverse...
Question: Calculate the sum of 2.6125x101 and 4.150390625 x 10-1 by hand, assuming A and B are stored in the 16-bit half precision described in Exercise 1. Assume 1 guard, 1 round bit, and 1 sticky bit, and round to the nearest even. Note: show all the steps for your calculation. Exercise 1: IEEE 754-2008 contains a half precision that it is only 16 bits wide. The leftmost bit is still the sign bit, the exponent is 5 bits wide...
IEEE 754-2008 contains a half precision that is only 16 bits wide. The leftmost bit is still the sign bit, the exponent is 5 bits wide and has a bias of 15, and the mantissa is 10 bits long. A hidden 1 is assumed. Write down the bit pattern to represent -1.6875 X 100 assuming a version of this format, which uses an excess-16 format to store the exponent. Comment on how the range and accuracy of this 16-bit floating...