# Is not defined for matrix correctness of your

• Notes
• 15

This preview shows 4 out of 15 pages.

^ is not defined for matrix!! Correctness of your function * is not %*% Efficiency of your function Format of your function You were instructed to use repeat, itmax, verbose, etc Format of submission The code directory with .R files The document directory with pdf files

Subscribe to view the full document.

MatPowerSeries <- function( x, itmax = 100, eps = 1e-6, verbose = FALSE) { d <- dim( x )[1]; A <- xnew <- xold <- diag( d ); itel <- 1; repeat{ A <- A %*% ( x / itel ) xnew <- xnew + A if( verbose ) { cat( "Iteration: ", formatC( itel, width = 3, format = "d"), "\n" ) cat( "xold: \n"); print( xold ) cat( "xnew: \n"); print( xnew ) cat( "\n" ) } if( ( max( abs( xnew - xold ) ) < eps ) || ( itel == itmax ) ){ return( xnew ) } xold <- xnew; itel <- itel + 1; } }
MatLimit<-function(x, itmax=100, eps=1e-6,verbose=FALSE) { d <- dim(x)[1]; Ident <- xold <- diag( d ); itel <- 1; repeat{ xnew <- Ident for( i in 1:itel ) { xnew <- xnew %*% ( Ident + x/itel ) } if ( verbose ) { cat( "Iteration: ", formatC( itel, width = 3, format = "d"), "\n" ) cat( "xold: \n" ); print( xold ) cat( "xnew: \n" ); print( xnew ) cat( "\n") } if ( ( max( abs( xnew - xold ) ) < eps ) || ( itel == itmax ) ){ return( xnew ) } xold <- xnew; itel <- itel + 1; } }

Subscribe to view the full document.

Subscribe to view the full document.

Subscribe to view the full document.

Subscribe to view the full document.

If there are empty cells then they should be replaced by zeroes. l <- ifelse(is.na(l),0,l) lmax <- max(l) xsum <- ifelse(is.na(xsum),0,xsum)

Subscribe to view the full document.

MyFunctionName <- function( PARAMETERS , itmax = 100, eps = 1e-6, verbose = FALSE) { # INITIAL PROCESS repeat{ # MAIN PROCESS if( verbose ) { # LOG PROCESS } if( ( CONDITION ) || ( itel == itmax ) ){ return( RETURNING VALUE ) } # SAVE OLD VALUE itel <- itel + 1; } }
You've reached the end of this preview.
• Fall '10
• JandeLeeuw
• Remainder, #, PDF files, OLD VALUE itel

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern