Differential Equations Solutions 7

Differential Equations Solutions 7 - be generated for...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 4 Solutions: Design of Computer Programs: Writing Your Legacy CHALLENGE 4.1. See posteddoc.m on the website. CHALLENGE 4.2. Data that a function needs should be speciFed in variables, not constants. This is Fne; C is a variable. Code should be modular, so that a user can pull out one piece and substi- tute another when necessary. The program posted factors a matrix into the product of two other matrices, and it would be easy to substitute a di±erent factorization algorithm. On the other hand, there is considerable overhead involved in function calls, so each module should involve a substantial computation in order to mask this overhead. This is also satisFed; posted performs a signiFcant computation ( O ( mn 2 ) operations). Input parameters should be tested for validity, and clear error messages should
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: be generated for invalid input. The factorization can be performed for any matrix or scalar, so input should be tested to be sure it is not a string, cell variable, etc. • “Spaghetti code” should be avoided. In other words, the sequence of instruc-tions should be top-to-bottom (including loops), without a lot of jumps in control. This is Fne, although there is a lot of nesting of loops. • The names of variables should be chosen to remind the reader of their purpose. The letter q is often used for an orthogonal matrix, and r is often used for an upper triangular one, but it would probably be better practice to use uppercase names for these matrices. 17...
View Full Document

This note was uploaded on 01/21/2012 for the course MAP 3302 taught by Professor Dr.robin during the Fall '11 term at University of Florida.

Ask a homework question - tutors are online