MATLAB PROGRAMMING MATRIX QUESTION 1 Write a function in Mat

MATLAB PROGRAMMING MATRIX QUESTION

1. Write a function in Matlab that takes as input the number n, the size of matrices and vectors; m, the number of nonzero elements of a sparse matrix; and the sparse matrix whose nonzeros are given in m-component column vectors r, c, and v: the rk row, ck column entry of the matrix is nonzero with value vk, for k = 1, . . . , m.

Finish the program in the following way:

(a) Have the function output the actual n × n matrix A represented. Write out or print out your function.

(b) Have the function accept also the input of x, an n-component vector, and, working directly with the r, c, and v, output the matrix-vector multiplication between the sparse matrix and the vector x, and the number of flops involved. Write out or print out your function.

(c) Assuming the sparse matrix is lower triangular and c is in non-decreasing order, have the function accept also the input of b, an n-component vector, and, working directly with the r, c, and v, output column-oriented forward substitution solving for A1 b, and the number of flops involved. Write out or print out your function

Solution

Create a sparse matrix with 10 nonzero values, but which has space allocated for 100 nonzero values.

The spalloc function is a shorthand way to create a sparse matrix with no nonzero elements but which has space allotted for some number of nonzeros.

MATLAB PROGRAMMING MATRIX QUESTION 1. Write a function in Matlab that takes as input the number n, the size of matrices and vectors; m, the number of nonzero el

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site