The general process is this:
- We assume you already have Java installed. However,
because of an issue with Java versions, you may need to re-install,
or install an older version - see below.
- Learn how to work at the command-line (Terminal in Mac,
Command-prompt in Windows).
- Learn how to add jar files to CLASSPATH (both Mac and Windows).
- Add lintool.jar and draw3d.jar to your
CLASSPATH and test them out.
There's a minor "headache" that needs to be overcome:
- We will be making extensive use of a tool called Draw3D
that uses the JavaFX library. JavaFX used to be included in
Java as a standard library until Java-10. Java-11 onwards,
unfortunately, has removed it.
- This means one of TWO options:
- Option 1: Install JavaFX separately and learn how
to use it, in order for Draw3D to work.
- Option 2: Install an older version of Java (Java 8 or
Java 10), and use that instead.
We'll show both options below.
First, start with these two steps:
Step 1: Practice working at the command-line
Step 2: Understand what environment variables are
Step 3: Make a folder for the course called linAlg
off of your Desktop:
- Mac: Use Finder to create this folder.
- Windows: Use Windows-Explorer.
For the remainder, we will assume:
- You have Java installed.
- You can write (edit) a simple Java program and compile and
execute at the command-line.
- You know how to create and edit environment variables.
Step 3: Download and test LinTool
LinTool is both a library and an interface for students in this course.
The interface is what you will use for your own implementations
of linear algebra, whereas the library has both default versions
and code that will test your implementation.
- Start by creating a directory called
lintool
under
the linAlg folder you've already created.
- You can use one of the following versions of
lintool
- So, which one should you use? This depends on how Draw3D gets
installed on your laptop. For now, simply use the latest version above
(3rd link) and come back here if you need an earlier version.
- Add lintool.jar to your CLASSPATH
variable.
- Test to see that it works by downloading
TestLinToolClasspath.java
into the testdir folder you've already made. Then,
open a Terminal (Mac-OS) or command-prompt (Windows), cd
to that directory and compile/execute.
- Congratulations! You are ready to begin implementation.
We'll take a small step towards implementation below.
- All you need by way of documentation are the javadoc descriptions
for the core classes of interest:
Step 4: Go a bit further with LinTool
Let's start down the road to implementation by understanding
how to use LinTool:
- The main idea is this: LinTool is an abstract
class that defines a number of methods that you will implement.
Each of these methods is a linear algebra computation.
- For example, examine the method that adds two real numbers
in LinTool.
It takes in two real numbers (as double's) and
should return the sum. Easy to implement, right?
- Let's implement just that method alone and subject the
implementation to testing.
- We will call our
implementation AliceLinTool.java
for our example user called Alice. You will of course use your
username instead. Meanwhile, let's examine the code:
import edu.gwu.lintool.*;
public class AliceLinTool extends LinToolEmpty {
// We'll now override the method that adds two real numbers.
public double add (double a, double b)
{
double c = a + b;
return c;
}
}
Note the following:
- We need to import the lintool package, at the top.
- The method signature (first line) is exactly the same
as described in the documenation of
LinTool.
- Only that one method was implemented inspite of the
fact that LinTool has many, many methods.
How is this possible? It is made possible because
LinTool provides a default so-called "empty"
implementation that implements all the methods.
The default implementation does nothing at all. Each
time you implement a method, your implementation overrides
the default implementation.
- Now download and save both
AliceLinTool.java
and a special test file called
TestLinTool.java in
the testdir you created a while back.
- Let's examine TestLinTool.java:
import edu.gwu.lintool.*;
public class TestLinTool {
public static void main (String[] argv)
{
AliceLinTool alice = new AliceLinTool ();
LinTest.testRealNumberAdd (alice);
}
}
Observe the following:
- This is a simple test file that creates an instance of
Alice's implementation and subjects it to a test.
- Again, the import statement is needed at the top.
- There is a mysterious method called testRealNumberAdd()
that takes Alice's implementation and subjects it to a test.
- Compile and run TestLinTool.java, and you'll see
that it passes the test.
- This is essentially the manner in which you will implement
and test your code. First you will implement a couple of methods
from LinTool, then you will test your implementation.
- To see a complete list of tests, examine the code in
AllLinToolTests.java.
- By the end of the semester, you will have written a linear
algebra toolkit.
Step 5: Draw3D
Draw3D is a 3D-drawing tool created by GW alum Bill Edison
for this course. (We will be eternally grateful.) The tool will help
us draw 3D vectors and visualize 3D examples more easily.
See this page on Draw3D
for more information on Draw3D, including instructions on how
to install.
NOTE: All the notes above are about implementing
code, but not about submission.
See this page for submission instructions.