svdDemo: Demonstrate the SVD for a 3 x 3 matrix

Description Usage Arguments Value Author(s) Examples

View source: R/svdDemo.R

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

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

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

Value

Nothing

Author(s)

Original idea from Duncan Murdoch

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
A <- matrix(c(1,2,0.1, 0.1,1,0.1, 0.1,0.1,0.5), 3,3)
svdDemo(A)

## Not run: 
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)

## End(Not run)

matlib documentation built on April 4, 2018, 5:03 p.m.