示例#1
0
        public Matrix1 unique()
        {
            List <double> list = new List <double>(_dims[0]);

            for (int i = 0; i < _dims[0]; i++)
            {
                list.Add(_arr[i]);
            }
            list.Sort();

            List <double> uniqueList = new List <double>();
            double        curItem    = (double)list[0];

            uniqueList.Add(curItem);
            for (int i = 0; i < list.Count; i++)
            {
                if (curItem != list[i])
                {
                    curItem = list[i];
                    uniqueList.Add(curItem);
                }
            }

            Matrix1 uniqueMat = new Matrix1(uniqueList.Count);

            for (int i = 0; i < uniqueList.Count; i++)
            {
                uniqueMat[i] = uniqueList[i];
            }
            return(uniqueMat);
        }
示例#2
0
        public Matrix1 Clone()
        {
            Matrix1 mat = new Matrix1(_dims[0]);

            for (int i = 1; i <= _dims[0]; i++)
            {
                mat[i] = this[i];
            }

            return(mat);
        }
示例#3
0
        public static Matrix1 operator *(Matrix1 mat1, Matrix1 mat2)
        {
            if (mat1.size(0) != mat2.size(0))
            {
                throw (new Exception("Both Operands should be of same size"));
            }

            Matrix1 newMatrix = new Matrix1(mat1.size(0));

            for (int x = 0; x < mat1.size(0); x++)
            {
                newMatrix[x] = mat1[x] * mat2[x];
            }

            return(newMatrix);
        }
示例#4
0
        public Matrix1 getCol(int col)
        {
            Matrix1 returned = new Matrix1(_dims[0]);

            if (col >= 0 && col < _dims[1])
            {
                for (int i = 0; i < _dims[0]; i++)
                {
                    returned[i] = this[i, col];
                }
            }
            else
            {
                throw (new Exception("Row is not in range"));
            }
            return(returned);
        }
示例#5
0
        public Matrix1 getRow(int row)
        {
            Matrix1 returned = new Matrix1(_dims[1]);

            if (row >= 0 && row < _dims[0])
            {
                for (int i = 0; i < _dims[1]; i++)
                {
                    returned[i] = this[row, i];
                }
            }
            else
            {
                throw (new Exception("Row is not in range"));
            }
            return(returned);
        }
示例#6
0
        public Matrix1 sort()
        {
            List <double> list = new List <double>(_dims[0]);

            for (int i = 0; i < _dims[0]; i++)
            {
                list.Add(_arr[i]);
            }
            list.Sort();

            Matrix1 uniqueMat = new Matrix1(list.Count);

            for (int i = 0; i < list.Count; i++)
            {
                uniqueMat[i] = list[i];
            }
            return(uniqueMat);
        }