## Class Subspace

    java.lang.Object
      Subspace

     class Subspace

extends java.lang.Object

This is the computational core of the package. It introduces subspaces and enables basic operations with them, using all the other classes for that.

Since:
  2014-04-01
Version:
  1.0
Author:
  Pavel Sikora <pavelsikora@mail.muni.cz>

Constructor Summary
`Subspace()` Constructs a null subspace.
`Subspace(Matrix A)` Constructs a subspace given in general form.
`Subspace(Point[] points, Vector[] vectors)` Constructs a subspace given in parametric form (ie. from at least one point and potentially some vectors).

Method Summary
`(package private) Cyclometric` `angle(Subspace W)` Calculates the angle of any two subspaces using the most efficient method.
`(package private) Cyclometric` `angleHyperplaneHyperplane(Subspace W)` Calculates the angle of two hyperplanes.
`(package private) Cyclometric` `angleLineAny(Subspace W)` Calculates the angle of a line and any other subspace.
`(package private) Cyclometric` `angleLineHyperplane(Subspace W)` Calculates the angle of a line and a hyperplane.
`(package private) Cyclometric` `angleLineLine(Subspace W)` Calculates the angle of two lines, ie. one-dimensional subspaces.
`(package private) Cyclometric` `angleUniversal(Subspace W)` Calculates the angle of two subspaces.
`(package private) void` `beautifyGeneral()` Multiplies individual equations by such numbers that their coefficients will be smallest possible integers.
`(package private) void` `beautifyParametric()` Multiplies individual vectors by such numbers that their coefficients will be smallest possible integers.
`(package private) void` `copy(Subspace S)` Copies the subspace.
`(package private) java.lang.String` `describe(char label)` Properly describes the subspace.
`(package private) SquareRootFraction` `distance(Subspace W)` Calculates the distance of any two subspaces using the most efficient method.
`(package private) SquareRootFraction` `distance(Subspace W, char firstLabel, char secondLabel, boolean verbose)` Calculates the distance of any two subspaces using the most efficient method.
`(package private) SquareRootFraction` `distanceFromParallelSubspace(Subspace W, char firstLabel, char secondLabel, boolean verbose)` Calculates the distance of the subspace from a parallel subspace.
`(package private) SquareRootFraction` `distancePointAny(Subspace W, char firstLabel, char secondLabel, boolean verbose)` Calculates the distance of a point from any subspace.
`(package private) SquareRootFraction` `distancePointHyperplane(Subspace W, char firstLabel, char secondLabel, boolean verbose)` Calculates the distance of a point from a hyperplane.
`(package private) SquareRootFraction` `distancePointPoint(Subspace W, char firstLabel, char secondLabel, boolean verbose)` Calculates the distance of two points.
`(package private) SquareRootFraction` `distanceUniversalUsingGram(Subspace W, char firstLabel, char secondLabel, boolean verbose)` Calculates the distance of any two subspaces using Gram determinant.
`(package private) static Subspace` `generateRandomHyperplane(int DIM)` Generates a random hyperplane in general form.
`(package private) static Subspace` `generateRandomHyperplaneWithIntegerNorm(int DIM)` Generates a random hyperplane in general form.
`(package private) static Subspace` `generateRandomSubspace(int dim, int DIM)` Generates a random subspace in general form.
`(package private) static Subspace[]` `generateRandomSubspacesWithGivenAngle(int dim1, int dim2, int DIM, PiFraction angle)` Generates two random subspaces in parametric form.
`(package private) static Subspace[]` `generateRandomSubspacesWithGivenDistance(int dim1, int dim2, int DIM, Fraction dist)` Generates two random subspaces in general form.
`(package private) Matrix` `getAugMatrix()` Returns the augmented matrix of equation system generating this subspace.
`(package private) int` `getDim()` Returns the dimension of the subspace.
`(package private) int` `getDIM()` Returns the dimension of the whole space (number of variables).
`(package private) int` `getDim(boolean verbose)` Returns the dimension of the subspace.
`(package private) int` `getDim(boolean verbose, char label)` Returns the dimension of the subspace.
`(package private) boolean` `getOriginalForm()` Makes clear if the subspace was originally input in general or in parametric form
`(package private) Matrix` `getVecMatrix()` Returns the matrix of direction vectors (in rows).
`(package private) void` `checkGeneralForm()` Checks if general form is already available; if it's not, it gets it.
`(package private) void` `checkGeneralForm(char label, boolean verbose)` Checks if general form is already available; if it's not, it gets it.
`(package private) void` `checkParametricForm()` Checks if parametric form is already available; if it's not, it gets it.
`(package private) void` `checkParametricForm(char label, boolean verbose)` Checks if parametric form is already available; if it's not, it gets it.
`(package private) Subspace` `intersectionDiffSpace(Subspace W)` Finds intersection of difference spaces of two subspaces.
`(package private) boolean` `intersects(Subspace W)` Checks, if this subspace intersects with the other.
`(package private) boolean` `intersects(Subspace W, char firstLabel, char secondLabel, boolean verbose)` Checks, if this subspace intersects with the other.
`(package private) boolean` `isGeneralFormAvailable()` Confirms if the general form is available.
`(package private) boolean` `isNull()` Checks, if this subspace is a null space.
`(package private) boolean` `isParallel(Subspace W)` Checks, if this subspace is parallel to the other.
`(package private) boolean` `isParallel(Subspace W, boolean verbose)` Checks, if this subspace is parallel to the other.
`(package private) boolean` `isParametricFormAvailable()` Confirms if the parametric form is available.
`(package private) Subspace` `orthogonalSupplement()` Finds orthogonal supplement to a subspace.
`(package private) java.lang.String` `toTeXGeneral()` Prints general form of this subspace formatted as TeX code.
`(package private) java.lang.String` `toTeXGeneral(char variable)` Prints general form of this subspace formatted as TeX code.
`(package private) java.lang.String` `toTeXParametric()` Prints parametric form of this subspace formatted as TeX code.
`(package private) java.lang.String` `toTextGeneral()` Prints general form of this subspace formatted as text.
`(package private) java.lang.String` `toTextGeneral(boolean verbose)` Prints general form of this subspace formatted as text.
`(package private) java.lang.String` `toTextGeneral(boolean verbose, char variable)` Prints general form of this subspace formatted as text.
`(package private) java.lang.String` `toTextParametric()` Prints parametric form of this subspace formatted as text.
`(package private) java.lang.String` `toTextParametric(boolean verbose)` Prints parametric form of this subspace formatted as text.

Methods inherited from class
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Subspace

    Subspace()

  Constructs a null subspace.

### Subspace

    Subspace(Matrix A)

  Constructs a subspace given in general form.

  Parameters:
    `A` - augmented matrix of equation system generating this subspace
  Throws:
    `java.lang.UnsupportedOperationException` - Throws an exception if the equation system is not solvable, and thus cannot generate a subspace.

### Subspace

    Subspace(Point[] points,
             Vector[] vectors)

  Constructs a subspace given in parametric form (ie. from at least one point and potentially some vectors).

  Parameters:
    `A` - augmented matrix of equation system generating this subspace
  Throws:
    `java.lang.IndexOutOfBoundsException` - Throws an exception if no reference point was given.

Method Detail

### angle

    Cyclometric angle(Subspace W)

  Calculates the angle of any two subspaces using the most efficient method.

  Parameters:
    `W` - the other subspace
  Returns:
    if the angle is any of 0, π/6, π/4, π/3, π/2, the returned object is the corresponding `PiFraction`; otherwise, the returned object is a double
  Throws:
    `java.lang.IllegalArgumentException` - Throws an exception if the two subspaces do not come from the same space, ie. they have a different `DIM`.

### angleHyperplaneHyperplane

    Cyclometric angleHyperplaneHyperplane(Subspace W)

  Calculates the angle of two hyperplanes.

  Parameters:
    `W` - the other hyperplane
  Returns:
    if the angle is any of 0, π/6, π/4, π/3, π/2, the returned object is a `PiFraction`; otherwise, the returned object is a double
  Throws:
    `java.lang.IllegalArgumentException` - Throws an exception if any of the two subspaces is not a hyperplane in fact.

### angleLineAny

    Cyclometric angleLineAny(Subspace W)

  Calculates the angle of a line and any other subspace.

  Parameters:
    `W` - the other subspace
  Returns:
    if the angle is any of 0, π/6, π/4, π/3, π/2, the returned object is a `PiFraction`; otherwise, the returned object is a double
  Throws:
    `java.lang.IllegalArgumentException` - Throws an exception if this subspaces is not a line.

### angleLineHyperplane

    Cyclometric angleLineHyperplane(Subspace W)

  Calculates the angle of a line and a hyperplane.

  Parameters:
    `W` - the hyperplane
  Returns:
    if the angle is any of 0, π/6, π/4, π/3, π/2, the returned object is a `PiFraction`; otherwise, the returned object is a double
  Throws:
    `java.lang.IllegalArgumentException` - Throws an exception if this subspaces is not a line or `W` is not a hyperplane.

### angleLineLine

    Cyclometric angleLineLine(Subspace W)

  Calculates the angle of two lines, ie. one-dimensional subspaces.

  Parameters:
    `W` - the other line
  Returns:
    if the angle is any of 0, π/6, π/4, π/3, π/2, the returned object is a `PiFraction`; otherwise, the returned object is a double
  Throws:
    `java.lang.IllegalArgumentException` - Throws an exception if any of the two subspaces is not a line in fact.

### angleUniversal

    Cyclometric angleUniversal(Subspace W)

  Calculates the angle of two subspaces.

  Parameters:
    `W` - the other subspace
  Returns:
    if the angle is any of 0, π/6, π/4, π/3, π/2, the returned object is a `PiFraction`; otherwise, the returned object is a double

### beautifyGeneral

    void beautifyGeneral()

  Multiplies individual equations by such numbers that their coefficients will be smallest possible integers.

### beautifyParametric

    void beautifyParametric()

  Multiplies individual vectors by such numbers that their coefficients will be smallest possible integers.

### copy

    void copy(Subspace S)

  Copies the subspace.

  Parameters:
    `S` - subspace to be copied

### describe

    java.lang.String describe(char label)

  Properly describes the subspace.

  Returns:
    type of the subspace (null space, point, line, plane, n-dimensional space, hyperplane, whole space)

### distance

    SquareRootFraction distance(Subspace W)

  Calculates the distance of any two subspaces using the most efficient method. This method doesn't “talk” (creates no text nor TeX output).

  Parameters:
    `W` - the other subspace
  Returns:
    the distance of the given subspaces
  Throws:
    `java.lang.IllegalArgumentException` - Throws an exception if the two subspaces do not come from the same space, ie. they have a different `DIM`

### distance

    SquareRootFraction distance(Subspace W,
                                char firstLabel,
                                char secondLabel,
                                boolean verbose)

  Calculates the distance of any two subspaces using the most efficient method.

  Parameters:
    `W` - the other subspace
    `verbose` - determines, if the method “talks” (creates any text and TeX output)
  Returns:
    the distance of the given subspaces
  Throws:
    `java.lang.IllegalArgumentException` - Throws an exception if the two subspaces do not come from the same space, ie. they have a different `DIM`

### distanceFromParallelSubspace

    SquareRootFraction distanceFromParallelSubspace(Subspace W,
                                                    char firstLabel,
                                                    char secondLabel,
                                                    boolean verbose)

  Calculates the distance of the subspace from a parallel subspace.

  Parameters:
    `W` - the other subspace, parallel to this one
    `verbose` - determines, if the method “talks” (creates any text and TeX output)
  Returns:
    the distance of this subspace from the parallel subspace

### distancePointAny

    SquareRootFraction distancePointAny(Subspace W,
                                        char firstLabel,
                                        char secondLabel,
                                        boolean verbose)

  Calculates the distance of a point from any subspace.

  Parameters:
    `W` - any subspace
    `verbose` - determines, if the method “talks” (creates any text and TeX output)
  Returns:
    the distance of the point from the given subspace
  Throws:
    `java.lang.IllegalArgumentException` - Throws an exception if this subspace is not a point.

### distancePointHyperplane

    SquareRootFraction distancePointHyperplane(Subspace W,
                                               char firstLabel,
                                               char secondLabel,
                                               boolean verbose)

  Calculates the distance of a point from a hyperplane.

  Parameters:
    `W` - the hyperplane
    `verbose` - determines, if the method “talks” (creates any text and TeX output)
  Returns:
    the distance of the point from the hyperplane
  Throws:
    `java.lang.IllegalArgumentException` - Throws an exception if this subspace is not a point or W is not a hyperplane.

### distancePointPoint

    SquareRootFraction distancePointPoint(Subspace W,
                                          char firstLabel,
                                          char secondLabel,
                                          boolean verbose)

  Calculates the distance of two points.

  Parameters:
    `W` - the other point
    `verbose` - determines, if the method “talks” (creates any text and TeX output)
  Returns:
    the distance of the points
  Throws:
    `java.lang.IllegalArgumentException` - Throws an exception if one of the spaces is not a point.

### distanceUniversalUsingGram

    SquareRootFraction distanceUniversalUsingGram(Subspace W,
                                                  char firstLabel,
                                                  char secondLabel,
                                                  boolean verbose)

  Calculates the distance of any two subspaces using Gram determinant.

  Parameters:
    `W` - the other subspace
    `verbose` - determines, if the method “talks” (creates any text and TeX output)
  Returns:
    the distance of the given subspaces

### generateRandomHyperplane

    static Subspace generateRandomHyperplane(int DIM)

  Generates a random hyperplane in general form.

  Parameters:
    `DIM` - dimension of the superspace (ie. a number of variables)

### generateRandomHyperplaneWithIntegerNorm

    static Subspace generateRandomHyperplaneWithIntegerNorm(int DIM)

  Generates a random hyperplane in general form. The length of the normal vector of the hyperplane will be an integer.

  Parameters:
    `DIM` - dimension of the superspace (ie. a number of variables)

### generateRandomSubspace

    static Subspace generateRandomSubspace(int dim,
                                           int DIM)

  Generates a random subspace in general form.

  Parameters:
    `dim` - dimension of the subspace (must be from [0, `DIM`))
    `DIM` - dimension of the superspace
  Throws:
    `java.lang.IndexOutOfBoundsException` - throws an exception if `dim` is not from [0, `DIM`)

### generateRandomSubspacesWithGivenAngle

    static Subspace[] generateRandomSubspacesWithGivenAngle(int dim1,
                                                            int dim2,
                                                            int DIM,
                                                            PiFraction angle)

  Generates two random subspaces in parametric form. The subspaces satisfy that their angle is a given number.

  Parameters:
    `dim1` - dimension of the first subspace (must be from [0, `DIM`))
    `dim2` - dimension of the second subspace (must be from [0, `DIM`))
    `DIM` - dimension of the superspace
    `angle` - angle of the subspaces
  Throws:
    `java.lang.IndexOutOfBoundsException` - throws an exception if `dim1` or `dim2` is not from [0, `DIM`)

### generateRandomSubspacesWithGivenDistance

    static Subspace[] generateRandomSubspacesWithGivenDistance(int dim1,
                                                               int dim2,
                                                               int DIM,
                                                               Fraction dist)

  Generates two random subspaces in general form. The subspaces satisfy that their distance is a given number.

  Parameters:
    `dim1` - dimension of the first subspace (must be from [0, `DIM`))
    `dim2` - dimension of the second subspace (must be from [0, `DIM`))
    `DIM` - dimension of the superspace
    `dist` - distance of the subspaces
  Throws:
    `java.lang.IndexOutOfBoundsException` - throws an exception if `dim1` or `dim2` is not from [0, `DIM`)

### getAugMatrix

    Matrix getAugMatrix()

  Returns the augmented matrix of equation system generating this subspace.

  Returns:
    augmented matrix

### getDim

    int getDim()

  Returns the dimension of the subspace.

  Returns:
    dimension of the subspace

### getDIM

    int getDIM()

  Returns the dimension of the whole space (number of variables).

  Returns:
    dimension of the whole space

### getDim

    int getDim(boolean verbose)

  Returns the dimension of the subspace. This method could also output the whole process of computing the dimension into text and tex files.

  Parameters:
    `verbose` - determines, if the method “talks” (creates any text and TeX output)
  Returns:
    dimension of the subspace

### getDim

    int getDim(boolean verbose,
               char label)

  Returns the dimension of the subspace. This method could also output the whole process of computing the dimension into text and tex files.

  Parameters:
    `label` - label of the subspace
    `verbose` - determines, if the method “talks” (creates any text and TeX output)
  Returns:
    dimension of the subspace

### getOriginalForm

    boolean getOriginalForm()

  Makes clear if the subspace was originally input in general or in parametric form

  Returns:
    true if subspace was generally input in general form, false if the original form was parametric

### getVecMatrix

    Matrix getVecMatrix()

  Returns the matrix of direction vectors (in rows).

  Returns:
    matrix of direction vectors

### checkGeneralForm

    void checkGeneralForm()

  Checks if general form is already available; if it's not, it gets it. This method doesn't “talk” (creates no text nor TeX output).

### checkGeneralForm

    void checkGeneralForm(char label,
                          boolean verbose)

  Checks if general form is already available; if it's not, it gets it.

  Parameters:
    `verbose` - determines, if the method “talks” (creates any text and TeX output)

### checkParametricForm

    void checkParametricForm()

  Checks if parametric form is already available; if it's not, it gets it. This method doesn't “talk” (creates no text nor TeX output).

### checkParametricForm

    void checkParametricForm(char label,
                             boolean verbose)

  Checks if parametric form is already available; if it's not, it gets it.

  Parameters:
    `verbose` - determines, if the method “talks” (creates any text and TeX output)

### intersectionDiffSpace

    Subspace intersectionDiffSpace(Subspace W)

  Finds intersection of difference spaces of two subspaces.

  Parameters:
    `W` - the other subspace
  Returns:
    the intersection of the difference spaces

### intersects

    boolean intersects(Subspace W)

  Checks, if this subspace intersects with the other. This method doesn't “talk” (creates no text nor TeX output).

  Parameters:
    `W` - the other subspace
  Returns:
    true, if the subspaces intersect, false otherwise

### intersects

    boolean intersects(Subspace W,
                       char firstLabel,
                       char secondLabel,
                       boolean verbose)

  Checks, if this subspace intersects with the other.

  Parameters:
    `W` - the other subspace
    `verbose` - determines, if the method “talks” (creates any text and TeX output)
  Returns:
    true, if the subspaces intersect, false otherwise

### isGeneralFormAvailable

    boolean isGeneralFormAvailable()

  Confirms if the general form is available.

  Returns:
    true if general form is available, false otherwise

### isNull

    boolean isNull()

  Checks, if this subspace is a null space.

  Returns:
    true, if dim < 0; false otherwise

### isParallel

    boolean isParallel(Subspace W)

  Checks, if this subspace is parallel to the other. This method doesn't “talk” (creates no text nor TeX output).

  Parameters:
    `W` - the other subspace
  Returns:
    true, if the subspaces are parallel, false otherwise

### isParallel

    boolean isParallel(Subspace W,
                       boolean verbose)

  Checks, if this subspace is parallel to the other.

  Parameters:
    `W` - the other subspace
    `verbose` - determines, if the method “talks” (creates any text and TeX output)
  Returns:
    true, if the subspaces are parallel, false otherwise

### isParametricFormAvailable

    boolean isParametricFormAvailable()

  Confirms if the parametric form is available.

  Returns:
    true if parametric form is available, false otherwise

### orthogonalSupplement

    Subspace orthogonalSupplement()

  Finds orthogonal supplement to a subspace.

  Returns:
    the orthogonal supplement to this subspace

### toTeXGeneral

    java.lang.String toTeXGeneral()

  Prints general form of this subspace formatted as TeX code.

  Returns:
    string formatted to general form

### toTeXGeneral

    java.lang.String toTeXGeneral(char variable)

  Prints general form of this subspace formatted as TeX code.

  Parameters:
    `variable` - label of the variables
  Returns:
    string formatted to general form

### toTeXParametric

    java.lang.String toTeXParametric()

  Prints parametric form of this subspace formatted as TeX code.

  Returns:
    string formatted to parametric form

### toTextGeneral

    java.lang.String toTextGeneral()

  Prints general form of this subspace formatted as text.

  Returns:
    indented string formatted to general form

### toTextGeneral

    java.lang.String toTextGeneral(boolean verbose)

  Prints general form of this subspace formatted as text.

  Parameters:
    `verbose` - determines if the output will be indented
  Returns:
    string formatted to general form

### toTextGeneral

    java.lang.String toTextGeneral(boolean verbose,
                                   char variable)

  Prints general form of this subspace formatted as text.

  Parameters:
    `verbose` - determines if the output will be indented
    `variable` - label of the variables
  Returns:
    string formatted to general form

### toTextParametric

    java.lang.String toTextParametric()

  Prints parametric form of this subspace formatted as text.

  Returns:
    string formatted to parametric form containing also “xi = ”

### toTextParametric

    java.lang.String toTextParametric(boolean verbose)

  Prints parametric form of this subspace formatted as text.

  Parameters:
    `verbose` - determines if the result shall contain full output (containing “xi = ”) = true; or short output (omitting “xi = ”) = false
  Returns:
    string formatted to parametric form