예제 #1
0
 public PurlinMatrix(Matrix2D matrix)
 {
     if (matrix.Width != matrix.Height)
         throw new ArgumentException("Purlin Matrix should be square");
     else
     {
         this.size = matrix.Width;
         downRow = new double[size];
         upperRow = new double[size];
         middleRow = new double[size];
         for (int i = 0; i < size; i++)
         {
             for (int j = 0; j < size; j++)
             {
                 if (Math.Abs(i - j) > 1 && matrix[i, j] != 0)
                     throw new ArgumentException("Invalid Matrix. Purlin matrix should be 3-diagonal");
                 else if (i == j)
                     middleRow[i] = matrix[i, j];
                 else if (i > j)
                     upperRow[i] = matrix[i, j];
                 else
                     downRow[j] = matrix[i, j];
             }
         }
     }
 }
예제 #2
0
 public Matrix2D GetSubMatrix(int index, Dimensions dimsType)
 {
     switch (dimsType)
     {
         case Dimensions.TimeDimension:
             throw new InvalidOperationException("Can't get submatrix for this dimension");
         case Dimensions.Thickness:
             if (index < thickness)
             {
                 Matrix2D result = new Matrix2D(width, height);
                 for (int i = 0; i < width; i++)
                 {
                     for (int j = 0; j < height; j++)
                     {
                         result[i, j] = this[i, j, index];
                     }
                 }
                 return result;
             }
             else
                 throw new ArgumentException("Invalid indexer");
         case Dimensions.Height:
             if (index < height)
             {
                 Matrix2D result = new Matrix2D(width, thickness);
                 for (int i = 0; i < width; i++)
                 {
                     for (int j = 0; j < thickness; j++)
                     {
                         result[i, j] = this[i, index, j];
                     }
                 }
                 return result;
             }
             else
                 throw new ArgumentException("Invalid indexer");
         case Dimensions.Width:
             if (index < width)
             {
                 Matrix2D result = new Matrix2D(height, thickness);
                 for (int i = 0; i < height; i++)
                 {
                     for (int j = 0; j < thickness; j++)
                     {
                         result[i, j] = this[index, i, j];
                     }
                 }
                 return result;
             }
             else
                 throw new ArgumentException("Invalid indexer");
         default:
             throw new Exception("Something strange has happened");
     }
 }
예제 #3
0
 public PurlinMatrix(Matrix2D matrix)
 {
     if (matrix.Width != matrix.Height)
     {
         throw new ArgumentException("Purlin Matrix should be square");
     }
     else
     {
         this.size = matrix.Width;
         downRow   = new double[size];
         upperRow  = new double[size];
         middleRow = new double[size];
         for (int i = 0; i < size; i++)
         {
             for (int j = 0; j < size; j++)
             {
                 if (Math.Abs(i - j) > 1 && matrix[i, j] != 0)
                 {
                     throw new ArgumentException("Invalid Matrix. Purlin matrix should be 3-diagonal");
                 }
                 else if (i == j)
                 {
                     middleRow[i] = matrix[i, j];
                 }
                 else if (i > j)
                 {
                     upperRow[i] = matrix[i, j];
                 }
                 else
                 {
                     downRow[j] = matrix[i, j];
                 }
             }
         }
     }
 }
예제 #4
0
        public Matrix2D GetSubMatrix(int index, Dimensions dimsType)
        {
            switch (dimsType)
            {
            case Dimensions.TimeDimension:
                throw new InvalidOperationException("Can't get submatrix for this dimension");

            case Dimensions.Thickness:
                if (index < thickness)
                {
                    Matrix2D result = new Matrix2D(width, height);
                    for (int i = 0; i < width; i++)
                    {
                        for (int j = 0; j < height; j++)
                        {
                            result[i, j] = this[i, j, index];
                        }
                    }
                    return(result);
                }
                else
                {
                    throw new ArgumentException("Invalid indexer");
                }

            case Dimensions.Height:
                if (index < height)
                {
                    Matrix2D result = new Matrix2D(width, thickness);
                    for (int i = 0; i < width; i++)
                    {
                        for (int j = 0; j < thickness; j++)
                        {
                            result[i, j] = this[i, index, j];
                        }
                    }
                    return(result);
                }
                else
                {
                    throw new ArgumentException("Invalid indexer");
                }

            case Dimensions.Width:
                if (index < width)
                {
                    Matrix2D result = new Matrix2D(height, thickness);
                    for (int i = 0; i < height; i++)
                    {
                        for (int j = 0; j < thickness; j++)
                        {
                            result[i, j] = this[index, i, j];
                        }
                    }
                    return(result);
                }
                else
                {
                    throw new ArgumentException("Invalid indexer");
                }

            default:
                throw new Exception("Something strange has happened");
            }
        }