Copy() public method

public Copy ( Matrix matrix2 ) : string
matrix2 Matrix
return string
Ejemplo n.º 1
0
        /// <summary>
        /// Copy one matrix to an existing matrix.
        /// The dimensions of the 2 matrices must be the same.
        /// </summary>
        /// <param name="matrix1">
        /// The matrix to copy from.
        /// </param>
        /// <param name="matrix2">
        /// The matrix to copy to.
        /// </param>
        /// <returns>
        /// "FAILED" or "" for success.
        /// </returns>
        public static Primitive Copy(Primitive matrix1, Primitive matrix2)
        {
            try
            {
                Matrix _matrix1 = getMatrix(matrix1);
                Matrix _matrix2 = getMatrix(matrix2);
                if (null == _matrix1 || null == _matrix2)
                {
                    return("FAILED");
                }

                return(_matrix1.Copy(_matrix2));
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                return("FAILED");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Copy one matrix to a new matrix.
        /// </summary>
        /// <param name="matrix">
        /// The matrix to copy.
        /// </param>
        /// <returns>
        /// A copy of the matrix or "FAILED".
        /// </returns>
        public static Primitive CopyNew(Primitive matrix)
        {
            try
            {
                Matrix _matrix1 = getMatrix(matrix);
                if (null == _matrix1)
                {
                    return("FAILED");
                }
                Matrix _matrix2 = new Matrix(_matrix1.rows, _matrix1.cols, getNewNumber());
                Matrices.Add(_matrix2);

                return(_matrix1.Copy(_matrix2) == "" ? _matrix2.name : "FAILED");
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                return("FAILED");
            }
        }