package Jampack;

/**
   Zdiagmat is a storage efficient representation of a complex
   diagonal matrix.

   @version Pre-alpha
   @author G. W. Stewart
*/

public class Zdiagmat{

/** The order of the matrix */
    protected int order;

/** The base index */
    protected int  basex;

/** The real part of the diagonal */
    protected double re[];

/** The imaginary part of the diagonal */
    protected double im[];

/** The order of the matrix (public) */
    public int n;

/** The base index (public) */
    public int bx;

/** The  index of the last diagonal (public) */
    public int dx;






/**
   Constructs a Zdiagmat and initializes it to zero.

   @param    order The order of the new Zdiagmat
   @return   A Zdiagmat initialized to zero.    
*/

   public Zdiagmat(int order){
      Parameters.BaseIndexNotChangeable = true;
      basex = Parameters.BaseIndex;
      this.order = order;
      getProperties();
      re = new double[n];
      im = new double[n];
   }

/**
   Constructs a Zdiagmat and initializes it to a constant.

   @param     order The order of the new Zdiagmat
   @param     val   The value to which the diagonal
                    is to be initialized
   @return    A Zdiagmat whose diagonal is val.
*/

   public Zdiagmat(int order, Z val){
      Parameters.BaseIndexNotChangeable = true;
      basex = Parameters.BaseIndex;
      this.order = order;
      getProperties();
      re = new double[n];
      im = new double[n];
      for (int i=0; i0, the kth superdiagonal; k<0, the kth subdiagonal.
   @return    The Zdiagmat consisting of the selected diagonal of A
   @exception JampackException
              Thrown for k to large or small.
*/

   public Zdiagmat(Zmat A, int k)
   throws JampackException{
      Parameters.BaseIndexNotChangeable = true;
      basex = Parameters.BaseIndex;
      if (k >= 0){
         if (k >= A.ncol){
            throw new JampackException
               ("Diagonal out of range.");
         }
         order = Math.min(A.nrow, A.ncol-k);
         re = new double[order];
         im = new double[order];
         for (int i=0; i= A.nrow){
            throw new JampackException
               ("Diagonal out of range.");
         }
         order = Math.min(A.nrow-k, A.ncol);
         re = new double[order];
         im = new double[order];
         for (int i=0; iith diagonal of a of a Zdiagmat
   (0-based).
*/

   public Z get0(int i){

      return new Z(re[i], im[i]);
   }


/**
   Writes the ii-th diagonal element of a Zdiagmat.

   @param     ii  An integer
   @param     val A Z
   @return    Resets the ii-th diagonal element of this Zdiagmat
              to val.
*/

   public void put(int ii, Z val){

      re[ii-bx] = val.re;
      im[ii-bx] = val.im;
   }

/**
   Writes the ith diagonal element  of a Zdiagmat
   (0-based).
*/

   public void put0(int i, Z val){

      re[i] = val.re;
      im[i] = val.im;
   }

}


 

Ads help maintain this website.