Question

In: Advanced Math

Use Octave Given a matrix M ∈ M mn , each function should first ensure that...

Use Octave

Given a matrix M ∈ M mn , each function should first ensure that the matrix has the proper size (e.g., be
square if the definition involves a square matrix). Until CA4, we do not implement proper error handling,
so for now, if the matrix is not of the proper size, the function should return FALSE. In this assignment,
we create functions that characterise matrix properties or types. These definitions can be found easily. For
reference, the location of some of the definitions in the Horn & Johnson book is provided. The following
functions should be made available:  
1. is_ real _matrix(M) is true if M ∈ M(R).
2. is _complex _matrix(M) is true if M ∈ M(C) and ∃i,j such that =(m ij ) 6= 0.
3. is _diagonal_ matrix(M) is true if M ∈ M(C) is a diagonal matrix (H&J 0.9.1).
4. is_ lower _triangular_ matrix(M) is true if M ∈ M(C) is a lower triangular matrix (H&J 0.9.3).
5. is _upper _triangular_ matrix(M) is true if M ∈ M(C) is an upper triangular matrix (H&J 0.9.3).
6. is _triangular _matrix(M) is true if M ∈ M(C) is a triangular matrix (H&J 0.9.3).
7. is _symmetric_ matrix(M) is true if M ∈ M(C) is a symmetric matrix.
8. is -hermitian _matrix(M) is true if M ∈ M(C) is a Hermitian matrix.
9. is_ skew _hermitian _matrix(M) is true if M ∈ M(C) is a skew Hermitian matrix.
10. is_ normal _matrix(M) is true if M ∈ M(C) is a normal matrix.
11. is _unitary_ matrix(M) is true if M ∈ M(C) is a unitary matrix.
12. is_ orthogonal_ matrix(M) is true if M ∈ M(C) is an orthogonal matrix.
13. is_ permutation _matrix(M) is true if M ∈ M(C) is a permutation matrix (H&J 0.9.5).
14. is _reversal_ matrix(M) is true if M ∈ M(C) is a reversal matrix (H&J 0.9.5).
15. is _circulant _matrix(M) is true if M ∈ M(C) is a circulant matrix (H&J 0.9.6).
16. is _Toeplitz_ matrix(M) is true if M ∈ M(C) is a Toeplitz matrix (H&J 0.9.7).
17. is _Hankel _matrix(M) is true if M ∈ M(C) is a Hankel matrix (H&J 0.9.8).
18. is _lower_ Hessenberg matrix(M) is true if M ∈ M(C) is a lower Hessenberg matrix (H&J 0.9.9).
19. is_ upper_Hessenberg matrix(M) is true if M ∈ M(C) is an upper Hessenberg matrix (H&J 0.9.9).
20. is _tridiagonal_ matrix(M) is true if M ∈ M(C) is a tridiagonal matrix (H&J 0.9.10).
21. is _Jacobi _matrix(M) is true if M ∈ M(C) is a Jacobi matrix (H&J 0.9.10).
22. is_ persymmetric_ matrix(M) is true if M ∈ M(C) is a persymmetric matrix (H&J 0.9.10).

Solutions

Expert Solution

1. function is_real_matrix(M)
count=0;
for i=M
if(!isreal(i))
fprintf("\n The matrix has non real entries.")
count=count+1;
endif
endfor
if(!count)
fprintf("\n The matrix is real ! \n")
endif
endfunction

2. function is_complex_matrix(M)
count=0;
for i=M
if(iscomplex(i))
fprintf("\n The matrix has complex entries.")
count=count+1;
endif
endfor
if(!count)
fprintf("\n The matrix is not complex! \n")
endif
endfunction

3. function is_diagonal_matrix(M)
[c,d]=size(M)
if(c-d)
fprintf("\n The matrix is not square \n")
elseif (!(c-d))
if(isdiag(a))
fprintf("\n The matrix is diagonal!\n")
else
fprintf("\n It is not diagonal!\n")
endif
endif
endfunction

4. function is_lower_triangular_matrix(M)
[c,d]=size(M)
if(c-d)
fprintf("\n The matrix is not square \n")
elseif (!(c-d))
if(istril(a))
fprintf("\n The matrix is lower triangular!\n")
else
fprintf("\n It is not lower triangular!\n")
endif
endif
endfunction


Related Solutions

use matlab to create a function that finds inverse of 2x2 matrix and returns result. Should...
use matlab to create a function that finds inverse of 2x2 matrix and returns result. Should be a error check to make sure matrix is 2x2, and nonsingular.
(15) There are two groups of individuals, each with a utility function given by U(M)=√M, where...
(15) There are two groups of individuals, each with a utility function given by U(M)=√M, where M=8,100 is the initial wealth level for every individual. The fraction of group 1 is 3/4 . Each member of group faces a loss of 7,200 with probability 1/2. Each member of group faces a loss of 3,200 with probability 1/2. Assume that the insurance market is perfectively competitive. And the insurance company does not know who belongs to which group. (5) What is...
What solution and indicator should I use to determine a mixture of Mn and Fe?
What solution and indicator should I use to determine a mixture of Mn and Fe?
Use double induction to prove that (m+ 1)^n> mn for all positive integers m; n
Use double induction to prove that (m+ 1)^n> mn for all positive integers m; n
Given the matrix A (2x2 matrix taking the first two column vectors from the input file),...
Given the matrix A (2x2 matrix taking the first two column vectors from the input file), compute the followings. Λ: the diagonal matrix whose diagonal elements are the corresponding eignevalues Λii = λi for i=1,2 R: the 2x2 matrix whose ith column vector is the eigenvector corresponding to λi for i=1,2 RΛRT: the matrix compositions 1/0: the comparison between A and RΛRT (is A= RΛRT?) Your output should have seven lines where the first two lines correspond to the 2x2...
Matlab You will write a function to calculate the determinant of a matrix. It should work...
Matlab You will write a function to calculate the determinant of a matrix. It should work for any size matrix. Remember that the determinant can be calculated by multiplying the diagonal elements of an upper right triangular matrix. Your function will take a matrix passed to it and put it in upper right triangular form. You will work down the diagonal beginning at row 1 column 1, then row 2 column 2, etc. Note that the row and column numbers...
maximumST is a function that should take an n × n vector (representing the adjacency matrix...
maximumST is a function that should take an n × n vector (representing the adjacency matrix of a graph) as input and return the value of the maximum spanning tree of the graph defined by the n × n vector. Code: #include <vector> #include <cmath> #include <iostream> #include <cstdio> using namespace std; double maximumST( vector< vector<double> > adjacencyMatrix ){   vector<int> row(4,-1);   vector< vector<int> > matrix(5,row);   cerr << matrix.size() << endl;   cerr << matrix[0].size() << endl;   for( int i = 0;...
20) For the given cost function C(x)=22500+800x+x2, First, find the average cost function. Use it to...
20) For the given cost function C(x)=22500+800x+x2, First, find the average cost function. Use it to find: a) The production level that will minimize the average cost? 21) Given the function f(t)=(t−3)(t+7)(t−6). its f-intercept is   its t-intercepts are b) The minimal average cost?
Use this theorem to find the inverse of the given matrix or show that no inverse...
Use this theorem to find the inverse of the given matrix or show that no inverse exists. (If an answer does not exist, enter DNE in any cell.) 1    2    5    1 −1    0    2    1 2    1    −5    0 1    1    2    1
C++ Code each of the following functions RECURSIVELY  (each function should use only the parameter value, and...
C++ Code each of the following functions RECURSIVELY  (each function should use only the parameter value, and any local function variables you might need ..no variables are to be declared outside the functions). void upTo(int number) This function prints all values from 1 up to the number. upTo(5); should output: 1 2 3 4 5 HINT: the following functions involve separating a digit from a number. Use of the arithmetic operators % and / are helpful here. Remember a % 10...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT