Learn R Programming

matlib (version 1.0.0)

svdDemo: Demonstrate the SVD for a 3 x 3 matrix

Description

This function draws an rgl scene consisting of a representation of the identity matrix and a 3 x 3 matrix A, together with the corresponding representation of the matrices U, D, and V in the SVD decomposition, A = U D V'.

Usage

svdDemo(A, shape = c("cube", "sphere"), alpha = 0.7, col = rainbow(6))

Value

Nothing

Arguments

A

A 3 x 3 numeric matrix

shape

Basic shape used to represent the identity matrix: "cube" or "sphere"

alpha

transparency value used to draw the shape

col

Vector of 6 colors for the faces of the basic cube

Author

Original idea from Duncan Murdoch

Examples

Run this code
A <- matrix(c(1,2,0.1, 0.1,1,0.1, 0.1,0.1,0.5), 3,3)
svdDemo(A)

if (FALSE) {
B <- matrix(c( 1, 0, 1, 0, 2, 0,  1, 0, 2), 3, 3)
svdDemo(B)

# a positive, semi-definite matrix with eigenvalues 12, 6, 0
C <- matrix(c(7, 4, 1,  4, 4, 4,  1, 4, 7), 3, 3)
svdDemo(C)
}

Run the code above in your browser using DataLab