Modify class description

This commit is contained in:
2014-03-15 12:00:03 +01:00
parent 13c23aafa8
commit bf68ba4560
41 changed files with 205 additions and 186 deletions

View File

@@ -11,6 +11,9 @@ import physics.Nyquist;
import stdlib.Color; import stdlib.Color;
import stdlib.StdDraw; import stdlib.StdDraw;
/**
* @author Daniel Weschke
*/
public class Draw extends StdDraw{ public class Draw extends StdDraw{
static Thread plot; static Thread plot;
static JLabel infoLabel; static JLabel infoLabel;

View File

@@ -1,5 +1,8 @@
package exception; package exception;
/**
* @author Daniel Weschke
*/
public class ComplexException extends Exception { public class ComplexException extends Exception {
/** /**

View File

@@ -1,5 +1,8 @@
package exception; package exception;
/**
* @author Daniel Weschke
*/
public class IllegalDimensionException extends Exception { public class IllegalDimensionException extends Exception {
/** /**

View File

@@ -1,5 +1,8 @@
package exception; package exception;
/**
* @author Daniel Weschke
*/
public class IllegalSetupException extends Exception { public class IllegalSetupException extends Exception {
/** /**

View File

@@ -1,5 +1,8 @@
package exception; package exception;
/**
* @author Daniel Weschke
*/
public class NoSquareException extends Exception { public class NoSquareException extends Exception {
private static final long serialVersionUID = -4049443845429534140L; private static final long serialVersionUID = -4049443845429534140L;

View File

@@ -1,5 +1,8 @@
package exception; package exception;
/**
* @author Daniel Weschke
*/
public class SingularException extends Exception { public class SingularException extends Exception {
private static final long serialVersionUID = -5121014712549208662L; private static final long serialVersionUID = -5121014712549208662L;

View File

@@ -1,6 +1,5 @@
/** /**
* Exceptions * Exceptions
*
* @author Daniel Weschke * @author Daniel Weschke
*/ */
package exception; package exception;

View File

@@ -14,9 +14,7 @@ import exception.NoSquareException;
import exception.SingularException; import exception.SingularException;
/** /**
*
* @author Daniel Weschke * @author Daniel Weschke
*
*/ */
public class Polynomial{ public class Polynomial{
protected String symbolic = "x"; protected String symbolic = "x";

View File

@@ -2,7 +2,9 @@ package math.equation;
import math.number.NumberComplex; import math.number.NumberComplex;
/**
* @author Daniel Weschke
*/
public class PolynomialComplex { public class PolynomialComplex {
private Polynomial re; private Polynomial re;
private Polynomial im; private Polynomial im;

View File

@@ -1,6 +1,8 @@
package math.equation; package math.equation;
/**
* @author Daniel Weschke
*/
public class RationalPolynomial { public class RationalPolynomial {
public Polynomial a; public Polynomial a;
public Polynomial b; public Polynomial b;

View File

@@ -3,10 +3,8 @@ package math.equation;
import math.number.NumberComplex; import math.number.NumberComplex;
/** /**
* quotient * quotient ( a(x) + b(x)i ) / ( c(x) + d(x)i )
* a(x) + b(x)i / c(x) + d(x)i * @author Daniel Weschke
* @author Daniel
*
*/ */
public class RationalPolynomialComplex { public class RationalPolynomialComplex {

View File

@@ -4,6 +4,9 @@ import java.text.DecimalFormat;
import math.matrix.Vector; import math.matrix.Vector;
/**
* @author Daniel Weschke
*/
public class Point { public class Point {
protected double[] point; protected double[] point;
protected int n; protected int n;

View File

@@ -1,5 +1,8 @@
package math.geometry; package math.geometry;
/**
* @author Daniel Weschke
*/
public class PointPolar { public class PointPolar {
double r; double r;
double theta; double theta;

View File

@@ -1,13 +1,9 @@
package math.geometry; package math.geometry;
/************************************************************************* /**
* Compilation: javac PointPolar.java
* Execution: java PointPolar
*
* Implementation of 2D point using polar coordinates. * Implementation of 2D point using polar coordinates.
* * @author Daniel Weschke
*************************************************************************/ */
public final class PointPolar2D { public final class PointPolar2D {
private final double r; private final double r;
private final double theta; private final double theta;
@@ -38,8 +34,6 @@ public final class PointPolar2D {
public String toString() { return "(" + x() + ", " + y() + ")"; } public String toString() { return "(" + x() + ", " + y() + ")"; }
// test client // test client
public static void main(String[] args) { public static void main(String[] args) {
PointPolar2D p = new PointPolar2D(); PointPolar2D p = new PointPolar2D();

View File

@@ -2,16 +2,17 @@ package math.matrix;
import java.io.Serializable; import java.io.Serializable;
/** Cholesky Decomposition. /**
<P> * Cholesky Decomposition.
For a symmetric, positive definite matrix A, the Cholesky decomposition * <P>
is an lower triangular matrix L so that A = L*L'. * For a symmetric, positive definite matrix A, the Cholesky decomposition
<P> * is an lower triangular matrix L so that A = L*L'.
If the matrix is not symmetric or positive definite, the constructor * <P>
returns a partial decomposition and sets an internal flag that may * If the matrix is not symmetric or positive definite, the constructor
be queried by the isSPD() method. * returns a partial decomposition and sets an internal flag that may
*/ * be queried by the isSPD() method.
* @author Daniel Weschke
*/
public class CholeskyDecomposition implements Serializable { public class CholeskyDecomposition implements Serializable {
/* ------------------------ /* ------------------------

View File

@@ -2,6 +2,11 @@ package math.matrix;
import exception.IllegalDimensionException; import exception.IllegalDimensionException;
/**
* Diagonal matrix object d<sub>ij</sub>&isin;&#x211D;, i&ne;j=0
* with m rows and n columns
* @author Daniel Weschke
*/
public class Diagonal extends Matrix{ public class Diagonal extends Matrix{
/** /**

View File

@@ -1,7 +1,10 @@
package math.matrix; package math.matrix;
/**
* 2D diagonal matrix object d<sub>ij</sub>&isin;&#x211D;, i&ne;j=0
* with 2 rows and 2 columns
* @author Daniel Weschke
*/
public class Diagonal2D extends Matrix2D { public class Diagonal2D extends Matrix2D {
/** /**
@@ -9,14 +12,10 @@ public class Diagonal2D extends Matrix2D {
*/ */
private static final long serialVersionUID = 553077525134866149L; private static final long serialVersionUID = 553077525134866149L;
public Diagonal2D(int n){ public Diagonal2D(){
this(n,n); m = 2;
} n = 2;
data = new double[2];
public Diagonal2D(int m, int n){
this.m = m;
this.n = n;
data = new double[m>n?m:n];
} }
/** /**
@@ -27,7 +26,7 @@ public class Diagonal2D extends Matrix2D {
*/ */
public static Diagonal2D identity(int n){ public static Diagonal2D identity(int n){
int i; int i;
Diagonal2D c = new Diagonal2D(n); Diagonal2D c = new Diagonal2D();
for(i=0; i<n; i++) for(i=0; i<n; i++)
c.set(i, 1); c.set(i, 1);
return c; return c;

View File

@@ -4,22 +4,23 @@ import java.io.Serializable;
import math.Maths; import math.Maths;
/** Eigenvalues and eigenvectors of a real matrix. /**
<P> * Eigenvalues and eigenvectors of a real matrix.
If A is symmetric, then A = V*D*V' where the eigenvalue matrix D is * <P>
diagonal and the eigenvector matrix V is orthogonal. * If A is symmetric, then A = V*D*V' where the eigenvalue matrix D is
I.e. A = V.times(D.times(V.transpose())) and * diagonal and the eigenvector matrix V is orthogonal.
V.times(V.transpose()) equals the identity matrix. * I.e. A = V.times(D.times(V.transpose())) and
<P> * V.times(V.transpose()) equals the identity matrix.
If A is not symmetric, then the eigenvalue matrix D is block diagonal * <P>
with the real eigenvalues in 1-by-1 blocks and any complex eigenvalues, * If A is not symmetric, then the eigenvalue matrix D is block diagonal
lambda + i*mu, in 2-by-2 blocks, [lambda, mu; -mu, lambda]. The * with the real eigenvalues in 1-by-1 blocks and any complex eigenvalues,
columns of V represent the eigenvectors in the sense that A*V = V*D, * lambda + i*mu, in 2-by-2 blocks, [lambda, mu; -mu, lambda]. The
i.e. A.times(V) equals V.times(D). The matrix V may be badly * columns of V represent the eigenvectors in the sense that A*V = V*D,
conditioned, or even singular, so the validity of the equation * i.e. A.times(V) equals V.times(D). The matrix V may be badly
A = V*D*inverse(V) depends upon V.cond(). * conditioned, or even singular, so the validity of the equation
**/ * A = V*D*inverse(V) depends upon V.cond().
* @author Daniel Weschke
*/
public class EigenvalueDecomposition implements Serializable { public class EigenvalueDecomposition implements Serializable {
/** /**

View File

@@ -14,6 +14,7 @@ import java.io.Serializable;
* singular, so the constructor will never fail. The primary use of the * singular, so the constructor will never fail. The primary use of the
* LU decomposition is in the solution of square systems of simultaneous * LU decomposition is in the solution of square systems of simultaneous
* linear equations. This will fail if isNonsingular() returns false. * linear equations. This will fail if isNonsingular() returns false.
* @author Daniel Weschke
*/ */
public class LUDecomposition implements Serializable { public class LUDecomposition implements Serializable {

View File

@@ -20,7 +20,7 @@ import exception.NoSquareException;
import exception.SingularException; import exception.SingularException;
/** /**
* Matrix object M&isin;&#x211D; * Matrix object m<sub>ij</sub>&isin;&#x211D;
* with m rows and n columns * with m rows and n columns
* @author Daniel Weschke * @author Daniel Weschke
* @version 01 November 2013 * @version 01 November 2013

View File

@@ -9,9 +9,9 @@ import exception.NoSquareException;
import exception.SingularException; import exception.SingularException;
/** /**
* Matrix 2xn, m is always 2 * 2D matrix object m<sub>ij</sub>&isin;&#x211D;
* @author Daniel * with 2 rows and n columns
* * @author Daniel Weschke
*/ */
public class Matrix2D extends Matrix{ public class Matrix2D extends Matrix{

View File

@@ -6,7 +6,11 @@ import exception.ComplexException;
import exception.IllegalDimensionException; import exception.IllegalDimensionException;
import exception.NoSquareException; import exception.NoSquareException;
/**
* 3D matrix object m<sub>ij</sub>&isin;&#x211D;
* with 3 rows and n columns
* @author Daniel Weschke
*/
public class Matrix3D extends Matrix{ public class Matrix3D extends Matrix{
/** /**
* UID * UID

View File

@@ -15,6 +15,7 @@ import math.Maths;
* QR decomposition is in the least squares solution of nonsquare systems * QR decomposition is in the least squares solution of nonsquare systems
* of simultaneous linear equations. This will fail if isFullRank() * of simultaneous linear equations. This will fail if isFullRank()
* returns false. * returns false.
* @author Daniel Weschke
*/ */
public class QRDecomposition implements Serializable { public class QRDecomposition implements Serializable {

View File

@@ -16,6 +16,7 @@ import math.Maths;
* The singular value decompostion always exists, so the constructor will * The singular value decompostion always exists, so the constructor will
* never fail. The matrix condition number and the effective numerical * never fail. The matrix condition number and the effective numerical
* rank can be computed from this decomposition. * rank can be computed from this decomposition.
* @author Daniel Weschke
*/ */
public class SingularValueDecomposition implements Serializable { public class SingularValueDecomposition implements Serializable {

View File

@@ -1,5 +1,9 @@
package math.matrix; package math.matrix;
/**
* Second-order tensor (3x3 matrix).
* @author Daniel Weschke
*/
public class TensorII extends Matrix3D { public class TensorII extends Matrix3D {
/** /**

View File

@@ -4,9 +4,8 @@ import math.Maths;
import exception.IllegalDimensionException; import exception.IllegalDimensionException;
/** /**
* Tensor 2x2 * Second-order tensor (2x2 matrix).
* @author Daniel * @author Daniel Weschke
*
*/ */
public class TensorII2D extends Matrix2D { public class TensorII2D extends Matrix2D {

View File

@@ -11,7 +11,7 @@ import thisandthat.WObject;
import exception.IllegalDimensionException; import exception.IllegalDimensionException;
/** /**
* Vector of real numbers, v&isin;&#x211D;. * Vector of real numbers, v<sub>i</sub>&isin;&#x211D;.
* @author Daniel Weschke * @author Daniel Weschke
*/ */
public class Vector extends WObject implements Cloneable, Serializable{ public class Vector extends WObject implements Cloneable, Serializable{

View File

@@ -2,6 +2,10 @@ package math.matrix;
import exception.IllegalDimensionException; import exception.IllegalDimensionException;
/**
* 2D vector of real numbers, v<sub>i</sub>&isin;&#x211D;.
* @author Daniel Weschke
*/
public class Vector2D extends Vector{ public class Vector2D extends Vector{
/** /**

View File

@@ -2,6 +2,10 @@ package math.matrix;
import exception.IllegalDimensionException; import exception.IllegalDimensionException;
/**
* 3D vector of real numbers, v<sub>i</sub>&isin;&#x211D;.
* @author Daniel Weschke
*/
public class Vector3D extends Vector{ public class Vector3D extends Vector{
/** /**

View File

@@ -5,8 +5,7 @@ import thisandthat.WObject;
/** /**
* Complex vector v<sub>i</sub>&isin;&#x2102; * Complex vector v<sub>i</sub>&isin;&#x2102;
* @author Daniel * @author Daniel Weschke
*
*/ */
public class VectorComplex extends WObject{ public class VectorComplex extends WObject{
/** /**

View File

@@ -2,6 +2,9 @@ package math.number;
import thisandthat.WObject; import thisandthat.WObject;
/**
* @author Daniel Weschke
*/
public class Number extends WObject { public class Number extends WObject {
public static void main(String[] args) { public static void main(String[] args) {

View File

@@ -2,7 +2,6 @@ package math.number;
import math.Maths; import math.Maths;
/** /**
* Data type for complex number &isin;&#x2102; which defines complex arithmetic and * Data type for complex number &isin;&#x2102; which defines complex arithmetic and
* mathematical functions. * mathematical functions.

View File

@@ -2,7 +2,9 @@ package math.statistics;
import math.Maths; import math.Maths;
/**
* @author Daniel Weschke
*/
public class Probability { public class Probability {
/** /**

View File

@@ -14,6 +14,9 @@ import math.matrix.Vector;
import stdlib.StdDraw; import stdlib.StdDraw;
import awt.Draw; import awt.Draw;
/**
* @author Daniel Weschke
*/
public class Nyquist{ public class Nyquist{
Draw nyquist = new Draw(); Draw nyquist = new Draw();
static JTextField tf = new JTextField(); static JTextField tf = new JTextField();

View File

@@ -1,6 +1,8 @@
package stdlib; package stdlib;
/**
* @author Daniel Weschke
*/
public class Color extends java.awt.Color{ public class Color extends java.awt.Color{
/** /**

View File

@@ -1,62 +1,50 @@
package stdlib; package stdlib;
/*************************************************************************
* Compilation: javac StdArrayIO.java
* Execution: java StdArrayIO < input.txt
*
* A library for reading in 1D and 2D arrays of integers, doubles,
* and booleans from standard input and printing them out to
* standard output.
*
* % more tinyDouble1D.txt
* 4
* .000 .246 .222 -.032
*
* % more tinyDouble2D.txt
* 4 3
* .000 .270 .000
* .246 .224 -.036
* .222 .176 .0893
* -.032 .739 .270
*
* % more tinyBoolean2D.txt
* 4 3
* 1 1 0
* 0 0 0
* 0 1 1
* 1 1 1
*
* % cat tinyDouble1D.txt tinyDouble2D.txt tinyBoolean2D.txt | java StdArrayIO
* 4
* 0.00000 0.24600 0.22200 -0.03200
*
* 4 3
* 0.00000 0.27000 0.00000
* 0.24600 0.22400 -0.03600
* 0.22200 0.17600 0.08930
* 0.03200 0.73900 0.27000
*
* 4 3
* 1 1 0
* 0 0 0
* 0 1 1
* 1 1 1
*
*************************************************************************/
/** /**
* <i>Standard array IO</i>. This class provides methods for reading * <i>Standard array IO</i>. This class provides methods for reading
* in 1D and 2D arrays from standard input and printing out to * in 1D and 2D arrays of integers, doubles, and booleans from standard
* standard output. * input and printing out to standard output.
* <p> * <p>
* For additional documentation, see * For additional documentation, see
* <a href="http://introcs.cs.princeton.edu/22libary">Section 2.2</a> of * <a href="http://introcs.cs.princeton.edu/22libary">Section 2.2</a> of
* <i>Introduction to Programming in Java: An Interdisciplinary Approach</i> * <i>Introduction to Programming in Java: An Interdisciplinary Approach</i>
* by Robert Sedgewick and Kevin Wayne. * by Robert Sedgewick and Kevin Wayne.
* *
* @author Robert Sedgewick * % more tinyDouble1D.txt
* @author Kevin Wayne * 4
* .000 .246 .222 -.032
*
* % more tinyDouble2D.txt
* 4 3
* .000 .270 .000
* .246 .224 -.036
* .222 .176 .0893
* -.032 .739 .270
*
* % more tinyBoolean2D.txt
* 4 3
* 1 1 0
* 0 0 0
* 0 1 1
* 1 1 1
*
* % cat tinyDouble1D.txt tinyDouble2D.txt tinyBoolean2D.txt | java StdArrayIO
* 4
* 0.00000 0.24600 0.22200 -0.03200
*
* 4 3
* 0.00000 0.27000 0.00000
* 0.24600 0.22400 -0.03600
* 0.22200 0.17600 0.08930
* 0.03200 0.73900 0.27000
*
* 4 3
* 1 1 0
* 0 0 0
* 0 1 1
* 1 1 1
*
* @author Daniel Weschke
*/ */
public class StdArrayIO { public class StdArrayIO {

View File

@@ -1,28 +1,5 @@
package stdlib; package stdlib;
/*************************************************************************
* Compilation: javac StdDraw.java
* Execution: java StdDraw
*
* Standard drawing library. This class provides a basic capability for
* creating drawings with your programs. It uses a simple graphics model that
* allows you to create drawings consisting of points, lines, and curves
* in a window on your computer and to save the drawings to a file.
*
* Todo
* ----
* - Add support for gradient fill, etc.
*
* Remarks
* -------
* - don't use AffineTransform for rescaling since it inverts
* images and strings
* - careful using setFont in inner loop within an animation -
* it can cause flicker
*
*************************************************************************/
import java.awt.BasicStroke; import java.awt.BasicStroke;
import java.awt.FileDialog; import java.awt.FileDialog;
import java.awt.Font; import java.awt.Font;
@@ -63,13 +40,24 @@ import javax.swing.JMenuItem;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
/** /**
* <i>Standard draw</i>. This class provides a basic capability for * <i>Standard draw</i>. This class provides a basic capability for
* creating drawings with your programs. It uses a simple graphics model that * creating drawings with your programs. It uses a simple graphics model that
* allows you to create drawings consisting of points, lines, and curves * allows you to create drawings consisting of points, lines, and curves
* in a window on your computer and to save the drawings to a file. * in a window on your computer and to save the drawings to a file.
* <p> * <p>
* For additional documentation, see <a href="http://introcs.cs.princeton.edu/15inout">Section 1.5</a> of * For additional documentation, see <a href="http://introcs.cs.princeton.edu/15inout">Section 1.5</a> of
* <i>Introduction to Programming in Java: An Interdisciplinary Approach</i> by Robert Sedgewick and Kevin Wayne. * <i>Introduction to Programming in Java: An Interdisciplinary Approach</i> by Robert Sedgewick and Kevin Wayne.
* Todo
* ----
* - Add support for gradient fill, etc.
*
* Remarks
* -------
* - don't use AffineTransform for rescaling since it inverts
* images and strings
* - careful using setFont in inner loop within an animation -
* it can cause flicker
* @author Daniel Weschke
*/ */
public class StdDraw implements ActionListener, MouseListener, MouseMotionListener, KeyListener { public class StdDraw implements ActionListener, MouseListener, MouseMotionListener, KeyListener {

View File

@@ -1,29 +1,22 @@
package stdlib; package stdlib;
/*************************************************************************
* Compilation: javac StdIn.java
* Execution: java StdIn
*
* Reads in data of various types from standard input.
*
*************************************************************************/
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.util.Locale; import java.util.Locale;
import java.util.Scanner; import java.util.Scanner;
/** /**
* <i>Standard input</i>. This class provides methods for reading strings * <i>Standard input</i>. This class provides methods for reading strings
* and numbers from standard input. * and numbers from standard input.
* <p> * <p>
* The Locale used is: language = English, country = US. This is consistent * The Locale used is: language = English, country = US. This is consistent
* with the formatting conventions with Java floating-point literals, * with the formatting conventions with Java floating-point literals,
* command-line arguments (via <tt>Double.parseDouble()</tt>) * command-line arguments (via <tt>Double.parseDouble()</tt>)
* and standard output (via <tt>System.out.print()</tt>). It ensures that * and standard output (via <tt>System.out.print()</tt>). It ensures that
* standard input works with the input files used in the textbook. * standard input works with the input files used in the textbook.
* <p> * <p>
* For additional documentation, see <a href="http://introcs.cs.princeton.edu/15inout">Section 1.5</a> of * For additional documentation, see <a href="http://introcs.cs.princeton.edu/15inout">Section 1.5</a> of
* <i>Introduction to Programming in Java: An Interdisciplinary Approach</i> by Robert Sedgewick and Kevin Wayne. * <i>Introduction to Programming in Java: An Interdisciplinary Approach</i> by Robert Sedgewick and Kevin Wayne.
* @author Daniel Weschke
*/ */
public final class StdIn { public final class StdIn {

View File

@@ -1,24 +1,19 @@
package stdlib; package stdlib;
/*************************************************************************
* Compilation: javac StdOut.java
* Execution: java StdOut
*
* Writes data of various types to standard output.
*
*************************************************************************/
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Locale; import java.util.Locale;
/** /**
* <i>Standard output</i>. This class provides methods for writing strings * <i>Standard output</i>. This class provides methods for writing strings
* and numbers to standard output. * and numbers to standard output.
* <p> * <p>
* For additional documentation, see <a href="http://introcs.cs.princeton.edu/15inout">Section 1.5</a> of * For additional documentation, see
* <i>Introduction to Programming in Java: An Interdisciplinary Approach</i> by Robert Sedgewick and Kevin Wayne. * <a href="http://introcs.cs.princeton.edu/15inout">Section 1.5</a> of
* <i>Introduction to Programming in Java: An Interdisciplinary Approach</i>
* by Robert Sedgewick and Kevin Wayne.
* @author Daniel Weschke
*/ */
public final class StdOut { public final class StdOut {

View File

@@ -4,6 +4,9 @@ import java.util.Arrays;
import thisandthat.WObject; import thisandthat.WObject;
/**
* @author Daniel Weschke
*/
public class WString extends WObject{ public class WString extends WObject{
String str; String str;

View File

@@ -1,5 +1,8 @@
package thisandthat; package thisandthat;
/**
* @author Daniel Weschke
*/
public class WObject { public class WObject {
private static boolean supressErrorMessage = false; private static boolean supressErrorMessage = false;
private String name; private String name;