Week 11 Questions


Are character variables a string of numbers with letters and characters attached?

You can think of character variables at two levels. When you program, they are just variables that can contain strings of characters (letters are part of the characters). You can't do any calculations with them, so we downplay them a bit in a Programming for Engineers course, but they can be used to improve processing of input and to produce readable output. At the machine level, character variables are just another flag to the computer, telling it how to interpret the binary numbers (zero or positive integers) in memory. REAL tells it to look for an exponent in one place and mantissa in another. INTEGER tells it to do something simple to convert internal positive integers to something that represents either positive or negative integers. CHARACTER says to look in a translation table (usually ASCII) to interpret the binary integer in a byte of memory as a specific character (including but not limited to letters).

Why are CHARACTER variables such a big deal? Don't they just cover text on the screen?

Please re-read my introduction to CHARACTER variables and my discussion of the need for well documented input files. Character variables are the mechanism by which you clearly explain your input and output, making your life and the lives of anyone using your program much more tranquil.


How do you add the LINPACK subroutines to your Fortran Program?

I'll assume that you have 3 files: main.f containing the main program; sgefa.f containing the matrix factorization subroutine, and some routines from BLAS; and sgesl.f containing the linear system solution subroutine plus some more stuff. The quick way to do the job is to use the Unix "cat" command. At the Unix prompt type:

cat main.f sgefa.f sgesl.f > hw11.f

This combines the three files into a new file named hw11.f. The other option is to open the file containing your main program with "vi". Place the cursor in the last line of the file and type the command ":r sgefa.f". Move the cursor to the end of the file again and type ":r sgesl.f".

General Computing

How actually do we download the LINPACK subroutines after we see them? Should we be doing it on a Workstation?

On the NETSCAPE "File" menu you should find a "Save as" item. Click it, and select a name and subdirectory for your file. You will get the job done quicker if you do this on a Workstation. If you do it on a PC, you will then have to use FTP to move the file (be sure to click the ASCII button on the FTP transfer window).

How does a person run your examples from a CAC lab?

On a PC open the Internet access group and click on the Telnet icon. If the software doesn't ask immediately for a host name, select the Connect item from the File menu and enter one the Hammond machine names (e.g. h23.ptph.psu.edu). On a Mac look for BYU/NCSA Telnet. Once connected to the Hammond machine copy files that you need from my 201 directory to whatever your current directory is on the Hammond Workstation. If it is a simple example ending with ".f", compile it then execute. For example the recent example aorder.f can be copied with the command:

cp ~jhm/201/aorder.f .

Don't forget that final period telling "cp" to dump the copy into the current directory. Look at the file with "vi" or "view", and compile it with the command:

f77 aorder.f

Execute the program by typing "a.out".

My more recent examples are coming with shell scripts to cover compilation and execution, and at times copy files that they need. To use my latest examples make a subdirectory called leastsq ("mkdir leastsq"), change into the directory ("cd leastsq"), and then copy all of my files from my sample subdirectory:

cp ~jhm/201/leastsq/* .

Check for files beginning with "run", here you will find "runlin1" and "runlsq". Type "runlin1" and see what happens. If you get a messages complaining about privileges try typing "source runlin1". Take the time to inspect all ".f" and "run" files, along with any input files.

Class Procedures

I haven't had this linear algebra in class. Is this going to hurt my ability to understand and complete HW11?

Linear Algebra might help you. However, If you remember what you went through solving linear equations in Algebra, and the notation that I gave you today makes sense, then you should be fine. If my explanation and notes give you problems, stop by my office for more information.

Where can we get answers for the essay and "fill in the blank " questions on the test?

Check the postscript file for Exam 2 on the Web page.

If we ask you for our grades could you or Willie send them to us over E-mail

Yes, provided I don't get swamped with requests.

Can your explain how the extra optional Homework will be graded? Can we get hurt if we do it wrong?

Answer to the second question is no. Do the homework, and we will give you a number of points based on the quality of the work, up to the maximum listed. That is added to your total number of homework points. Your homework grade is based on your total points divided by "total possible points". Since I don't include the points for optional homeworks in "total possible points", you can only win by doing these exercises.

Computational Solution Methods

To solve the matrices, couldn't you use Kramer's rule? Is there anything in Netlib using Kramer's rule?

You can, but once you go beyond 3 equations and 3 unknowns Kramer's rule is vastly more expensive than Gauss Elimination for solving the equations. It has to do with the expense of evaluating a Determinant. Try counting operations for Kramer's on 3 equations, 4 equations and 5 equations. I've never even bothered to look for a Kramer's rule subroutine, and would be surprised to find one in LINPACK. By the way, another side benefit of LU decomposition is that the Determinant of the original matrix can be evaluated quickly by calculating the product of the Determinants of L and U.