// file: $isip/class/math/matrix/MatrixLong/MatrixLong.h // version: $Id: MatrixLong.h,v 1.2 1999/05/18 01:45:55 duncan Exp $ // // make sure definitions are only made once // #ifndef ISIP_MATRIX_LONG #define ISIP_MATRIX_LONG // isip include files // #ifndef ISIP_VECTOR_LONG #include #endif // forward declarations // class MatrixUshort; class MatrixUlong; class MatrixUllong; class MatrixShort; class MatrixLlong; class MatrixFloat; class MatrixDouble; class MatrixString; // MatrixLong: a vector of VectorLong's // class MatrixLong { //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: VectorLong** m_d; Long size_d; //--------------------------------------------------------------------------- // // public methods // //--------------------------------------------------------------------------- public: // required static methods // static String& name(); static boolean diagnose(long debug_level); // required methods // boolean debug(unichar* message); long size(); // initialization and release methods. init() is called at the // beginning of the constructor, release() in the destructor. these // methods allow for external methods to effectively construct or // delete objects, useful for inheritance and block memory // management. // boolean init(); boolean release(); // destructor/constructor(s) // ~MatrixLong(); MatrixLong(long nrows = DEF_SIZE, long ncols = DEF_SIZE); MatrixLong(MatrixLong& arg); MatrixLong(long nrows, long ncols, long* value); MatrixLong(VectorLong& dimensions, long value); // i/o methods // boolean get(Sof& sof, String& name, long tag); boolean get(Sof& sof, long tag); boolean put(Sof& sof, String& name, long tag); boolean put(Sof& sof, long tag); boolean read(Sof& sof, String& pname, long size = SofParser::FULL_OBJECT, boolean param = Integral::TRUE); boolean read(Sof& sof, long size = SofParser::FULL_OBJECT, boolean param = Integral::TRUE); boolean write(Sof& sof, String& name); boolean write(Sof& sof); // partial i/o methods // long getPartial(Sof& sof, String& name, long tag, long row_index); long getPartial(Sof& sof, long tag, long row_index); long getPartial(Sof& sof, String& name, long tag, long start_row, long num_rows, long start_col, long num_cols, boolean param = Integral::TRUE); long getPartial(Sof& sof, long tag, long start_row, long num_rows, long start_col, long num_cols, boolean param = Integral::TRUE); long readPartial(Sof& sof, String& pname, long start_row_index, boolean param = Integral::TRUE); long readPartial(Sof& sof, long row_index, boolean param = Integral::TRUE); long readPartial(Sof& sof, String& pname, long start_row, long num_rows, long start_col, long num_cols, boolean param = Integral::TRUE); long readPartial(Sof& sof, long start_row, long num_rows, long start_col, long num_cols, boolean param = Integral::TRUE); // inline methods // inline Long& operator()(long row_index, long col_index) { return ((VectorLong&)(*m_d[row_index]))(col_index); } inline VectorLong& operator()(long row_index) { return (VectorLong&)(*m_d[row_index]); } // automatic type conversions // operator long*(); // operator overloads // MatrixLong& operator= (MatrixLong& matrix); MatrixLong& operator= (long value); MatrixLong& operator+ (MatrixLong& matrix); MatrixLong& operator+ (long value); MatrixLong& operator- (MatrixLong& matrix); MatrixLong& operator- (long value); MatrixLong& operator* (MatrixLong& matrix); MatrixLong& operator* (long value); VectorLong& operator* (VectorLong& vector); MatrixLong& operator/ (long value); MatrixLong& operator+= (MatrixLong& matrix); MatrixLong& operator+= (long value); MatrixLong& operator-= (MatrixLong& matrix); MatrixLong& operator-= (long value); MatrixLong& operator*= (MatrixLong& matrix); MatrixLong& operator*= (long value); MatrixLong& operator/= (long value); MatrixLong& operator++ (); MatrixLong& operator-- (); MatrixLong& operator- (); boolean operator== (long value); boolean operator!= (long value); boolean operator> (long value); boolean operator< (long value); boolean operator>= (long value); boolean operator<= (long value); boolean operator== (MatrixLong& matrix); boolean operator!= (MatrixLong& matrix); // get methods // boolean get(MatrixUshort& arg); boolean get(MatrixUlong& arg); boolean get(MatrixUllong& arg); boolean get(MatrixShort& arg); boolean get(MatrixLong& arg); boolean get(MatrixLlong& arg); boolean get(MatrixFloat& arg); boolean get(MatrixDouble& arg); boolean get(MatrixString& arg); boolean get(String& arg); // assignment // boolean assign(long value); boolean assign(long start_row, long num_rows, long start_col, long num_cols, long value); boolean assign(MatrixUshort& arg); boolean assign(MatrixUlong& arg); boolean assign(MatrixUllong& arg); boolean assign(MatrixShort& arg); boolean assign(MatrixLong& arg); boolean assign(MatrixLlong& arg); boolean assign(MatrixFloat& arg); boolean assign(MatrixDouble& arg); boolean assign(MatrixString& arg); // Zhang: change SysChar to Char when Wu makes a Char class // boolean assign(VectorString& arg, SysChar delimiter = SysChar::SPACEC); boolean assign(String& arg, SysChar col_delim = SysChar::SPACEC, SysChar row_delim = DEF_ROW_DELIM); boolean assign(ushort* arg, long num_rows, long num_cols); boolean assign(ulong* arg, long num_rows, long num_cols); boolean assign(ullong* arg, long num_rows, long num_cols); boolean assign(short* arg, long num_rows, long num_cols); boolean assign(long* arg, long num_rows, long num_cols); boolean assign(llong* arg, long num_rows, long num_cols); boolean assign(float* arg, long num_rows, long num_cols); boolean assign(double* arg, long num_rows, long num_cols); boolean assign(String* arg, long num_rows, long num_cols); boolean assignCol(long col_index, VectorLong& vector); // resize methods // boolean resize(long nrows, long ncols = DEF_SIZE); boolean resize(VectorLong& dimensions); boolean resize(MatrixLong& prototype_matrix); boolean recreate(long nrows, long ncols = DEF_SIZE); boolean recreate(VectorLong& dimensions); boolean recreate(MatrixLong& prototype_matrix); // matrix dimension information // long getNumRows(); long getNumRows(long col_index); long getMaxNumCols(); VectorLong& getDimensions(); boolean checkDimensions(MatrixLong& arg); // string-like searching // long findFirstExactMatch(VectorLong& vector); long findBisectionSearch(VectorLong& vector); // unary methods // boolean neg(); boolean neg(MatrixLong& source_matrix); // relational and logical methods // boolean gt(long value); boolean lt(long value); boolean ge(long value); boolean le(long value); boolean eq(long value); boolean ne(long value); long numNotEqual(long value); boolean eq(MatrixLong& matrix); boolean ne(MatrixLong& matrix); // matrix arithmetic methods // boolean increment(long value); boolean increment(MatrixLong& source_vector, long value); boolean add(MatrixLong& source_matrix); boolean add(MatrixLong& m1, MatrixLong& m2); boolean add(long value); boolean add(MatrixLong& source_matrix, long value); boolean sub(MatrixLong& source_matrix); boolean sub(MatrixLong& m1, MatrixLong& m2); boolean sub(long value); boolean sub(MatrixLong& source_matrix, long value); boolean mult(MatrixLong& source_matrix); boolean mult(MatrixLong& m1, MatrixLong& m2); boolean mult(long value); boolean mult(MatrixLong& source_matrix, long value); boolean div(MatrixLong& source_matrix); boolean div(MatrixLong& m1, MatrixLong& m2); boolean div(long value); boolean div(MatrixLong& source_matrix, long value); // matrix vector arithmetic methods // boolean multv(VectorLong& output_vector, VectorLong& input_vector ); // mathematical methods // long min(); long min(long& row_index, long& col_index); long minMag(); long minMag(long& row_index, long& col_index); long max(); long max(long& row_index, long& col_index); long maxMag(); long maxMag(long& row_index, long& col_index); // vector to scalar mathematical methods // long determinant(); long sum(); long sumSq(); long avg(); long rms(); long var(); // other linear algebra stuff // boolean inverse(); boolean inverse(MatrixLong& matrix); boolean transpose(); boolean transpose(MatrixLong& matrix); // sub-matrix operations // long multiplyRowByColumn(MatrixLong& matrix_for_row, MatrixLong& matrix_for_col, long row_index, long col_index); long sumColumn(long col_index); long sumColumn(MatrixLong& matrix, long col_index); // concantenation // boolean concatByRow(MatrixLong& additional_rows); boolean concatByColumn(MatrixLong& additional_cols); // ordering/sorting // boolean reorderRows(VectorLong& indexes); boolean reorderRows(MatrixLong& matrix, VectorLong& indexes); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: //--------------------------------------------------------------------------- // // constants // //--------------------------------------------------------------------------- public: // define the class name // static const unichar CLASS_NAME[] = L"MatrixLong"; //---------------------------------------- // // io related variables // //---------------------------------------- static const unichar DEF_PARAM[] = L"values"; //---------------------------------------- // // default values and arguments // //---------------------------------------- // default arguments to methods // static const unichar DEF_ROW_DELIM = L','; // define the default value(s) of the class data // static const long DEF_VALUE = (long)0; static const long DEF_SIZE = (long)0; //---------------------------------------- // // error codes // //---------------------------------------- static const long ERR = (long)24600; }; // end of file // #endif