// FILE. . . . . d:/hak/hlt/src/hlt/math/matrix/sources/Vector.java
// EDIT BY . . . Hassan Ait-Kaci
// ON MACHINE. . Hak-Laptop
// STARTED ON. . Fri Nov 15 13:10:00 2019

/**
 * @version     Last modified on Mon Nov 18 10:48:21 2019 by hak
 * @author      <a href="mailto:hak@acm.org">Hassan A&iuml;t-Kaci</a>
 * @copyright   &copy; <a href="http://www.hassan-ait-kaci.net/">by the author</a>
 */

package hlt.math.matrix;

/**
 * This implements a one-dimensional vector of <tt>double</tt>s
 * assimilated to either a single-row or a single-column
 * <tt>Matrix</tt>.
 *
 * @see         RowVector
 * @see         ColVector
 * @see         Matrix
 */
public class Vector extends Matrix
{
  /**
   * Constructs a <tt>Vector</tt> of <tt>dimension</tt> elements as a
   * single-row or a single-column <tt>Matrix</tt> depending on whether
   * <tt>isRow</tt> is <tt>true</tt> or <tt>false</tt>.
   */
  public Vector (boolean isRow, int dimension)
  {
    if (isRow)
      super(1,dimension);
    else
      super(dimension,1);
  }

  /**
   * Constructs a row <tt>Vector</tt> of <tt>dimension</tt> elements.
   */
  public Vector (int dimension)
  {
    this(true,dimension);
  }

  public ColVector makeColVector ()
  {
    if (!isRowVector()) // already a column vector
      return (ColVector)this;
      
    ColVector column = new ColVector(length);
    
    for (int i = 0; i < length; i++)
      column[i] = data[0][i];

    return isRowVector = false;
  }

  /* ******************************************************************** */
}
