Mercurial > hg > octave-avbm
changeset 1574:dd7d27461567
[project @ 1995-10-19 04:34:20 by jwe]
author | jwe |
---|---|
date | Thu, 19 Oct 1995 04:34:44 +0000 |
parents | 403c60daa8c7 |
children | 6cc5d208c566 |
files | liboctave/Array-C.cc liboctave/Array-d.cc liboctave/Array-i.cc liboctave/Array-idx.h liboctave/Array.cc liboctave/Array.h liboctave/CDiagMatrix.h liboctave/CMatrix.cc liboctave/CMatrix.h liboctave/MArray.cc liboctave/MArray.h liboctave/Makefile.in liboctave/dDiagMatrix.h liboctave/dMatrix.cc liboctave/dMatrix.h liboctave/mx-base.h liboctave/mx-defs.h liboctave/mx-inlines.cc |
diffstat | 18 files changed, 138 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array-C.cc +++ b/liboctave/Array-C.cc @@ -35,9 +35,15 @@ template void assign (Array<Complex>&, const Array<Complex>&); template void assign (Array<Complex>&, const Array<double>&); +template void assign (Array<Complex>&, const Array<int>&); +template void assign (Array<Complex>&, const Array<short>&); +template void assign (Array<Complex>&, const Array<char>&); template void assign (Array2<Complex>&, const Array2<Complex>&); template void assign (Array2<Complex>&, const Array2<double>&); +template void assign (Array2<Complex>&, const Array2<int>&); +template void assign (Array2<Complex>&, const Array2<short>&); +template void assign (Array2<Complex>&, const Array2<char>&); /* ;;; Local Variables: ***
--- a/liboctave/Array-d.cc +++ b/liboctave/Array-d.cc @@ -32,8 +32,14 @@ template class DiagArray<double>; template void assign (Array<double>&, const Array<double>&); +template void assign (Array<double>&, const Array<int>&); +template void assign (Array<double>&, const Array<short>&); +template void assign (Array<double>&, const Array<char>&); template void assign (Array2<double>&, const Array2<double>&); +template void assign (Array2<double>&, const Array2<int>&); +template void assign (Array2<double>&, const Array2<short>&); +template void assign (Array2<double>&, const Array2<char>&); /* ;;; Local Variables: ***
--- a/liboctave/Array-i.cc +++ b/liboctave/Array-i.cc @@ -23,16 +23,26 @@ // Instantiate Arrays of integer values. +#define NO_DIAG_ARRAY 1 + #include "Array.h" #include "Array.cc" template class ArrayRep<int>; template class Array<int>; +template class Array2<int>; -// For now, we only need 1D arrays of integers. -// -// template class Array2<int>; -// template class DiagArray<int>; +#ifndef NO_DIAG_ARRAY +template class DiagArray<int>; +#endif + +template void assign (Array<int>&, const Array<int>&); +template void assign (Array<int>&, const Array<short>&); +template void assign (Array<int>&, const Array<char>&); + +template void assign (Array2<int>&, const Array2<int>&); +template void assign (Array2<int>&, const Array2<short>&); +template void assign (Array2<int>&, const Array2<char>&); /* ;;; Local Variables: ***
--- a/liboctave/Array-idx.h +++ b/liboctave/Array-idx.h @@ -293,10 +293,15 @@ int len = tmp.length (); - if (pcv_flag) - retval = Array2<T> (tmp, len, 1); + if (len == 0) + retval = Array2<T> (0, 0); else - retval = Array2<T> (tmp, 1, len); + { + if (pcv_flag) + retval = Array2<T> (tmp, len, 1); + else + retval = Array2<T> (tmp, 1, len); + } } else if (nr == 1 || nc == 1) { @@ -307,20 +312,29 @@ idx_vector *tmp = get_idx (); idx_vector idx = tmp[0]; - result_is_column_vector = idx.is_colon (); + if (idx.is_colon ()) + result_is_column_vector = 1; } Array<T> tmp = Array<T>::value (); int len = tmp.length (); - if (result_is_column_vector) - retval = Array2<T> (tmp, len, 1); + if (len == 0) + retval = Array2<T> (0, 0); else - retval = Array2<T> (tmp, 1, len); + { + if (result_is_column_vector) + retval = Array2<T> (tmp, len, 1); + else + retval = Array2<T> (tmp, 1, len); + } } else if (dfi_flag) { + // This code is only for indexing matrices. The vector + // cases are handled above. + idx_vector *tmp = get_idx (); idx_vector idx = tmp[0];
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -481,6 +481,7 @@ // A two-dimensional array with diagonal elements only. +#ifndef NO_DIAG_ARRAY #if 1 template <class T> T& @@ -640,6 +641,7 @@ if (--old_rep->count <= 0) delete old_rep; } +#endif /* ;;; Local Variables: ***
--- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -42,7 +42,10 @@ template <class T> class Array; template <class T> class Array2; template <class T> class Array3; + +#ifndef NO_DIAG_ARRAY template <class T> class DiagArray; +#endif #ifdef HEAVYWEIGHT_INDEXING #define SET_MAX_INDICES(n) set_max_indices (n) @@ -60,7 +63,10 @@ friend class Array<T>; friend class Array2<T>; friend class Array3<T>; + +#ifndef NO_DIAG_ARRAY friend class DiagArray<T>; +#endif private: @@ -286,6 +292,7 @@ set_max_indices (2); } +#ifndef NO_DIAG_ARRAY Array2 (const DiagArray<T>& a) : Array<T> (a.rows () * a.cols (), T (0)) { for (int i = 0; i < a.length (); i++) @@ -293,6 +300,7 @@ set_max_indices (2); } +#endif ~Array2 (void) { } @@ -443,6 +451,7 @@ // James Kanze email: kanze@us-es.sel.de // GABI Software, Sarl., 8 rue du Faisan, F-67000 Strasbourg, France +#ifndef NO_DIAG_ARRAY template <class T> class DiagArray : public Array<T> { @@ -631,6 +640,7 @@ void maybe_delete_elements (idx_vector& i, idx_vector& j); }; +#endif #endif
--- a/liboctave/CDiagMatrix.h +++ b/liboctave/CDiagMatrix.h @@ -44,7 +44,7 @@ ComplexDiagMatrix (void) : MDiagArray<Complex> () { } ComplexDiagMatrix (int n) : MDiagArray<Complex> (n) { } ComplexDiagMatrix (int n, const Complex& val) - : MDiagArray<Complex> (n, val) { } + : MDiagArray<Complex> (n, n, val) { } ComplexDiagMatrix (int r, int c) : MDiagArray<Complex> (r, c) { } ComplexDiagMatrix (int r, int c, const Complex& val) : MDiagArray<Complex> (r, c, val) { }
--- a/liboctave/CMatrix.cc +++ b/liboctave/CMatrix.cc @@ -105,6 +105,16 @@ elem (i, i) = a.elem (i, i); } +// XXX FIXME XXX -- could we use a templated mixed-type copy function +// here? + +ComplexMatrix::ComplexMatrix (const charMatrix& a) +{ + for (int i = 0; i < a.cols (); i++) + for (int j = 0; j < a.rows (); j++) + elem (i, j) = a.elem (i, j); +} + int ComplexMatrix::operator == (const ComplexMatrix& a) const {
--- a/liboctave/CMatrix.h +++ b/liboctave/CMatrix.h @@ -58,6 +58,8 @@ ComplexMatrix (const MDiagArray<Complex>& a) : MArray2<Complex> (a) { } ComplexMatrix (const ComplexDiagMatrix& a); + ComplexMatrix (const charMatrix& a); + ComplexMatrix& operator = (const ComplexMatrix& a) { MArray2<Complex>::operator = (a);
--- a/liboctave/MArray.cc +++ b/liboctave/MArray.cc @@ -222,6 +222,7 @@ // Two dimensional array with math ops. +#ifndef NO_DIAG_ARRAY template <class T> MArray2<T>::MArray2 (const MDiagArray<T>& a) : Array2<T> (a.rows (), a.cols (), T (0)) @@ -229,6 +230,7 @@ for (int i = 0; i < a.length (); i++) elem (i, i) = a.elem (i, i); } +#endif // Element by element MArray2 by scalar ops. @@ -365,6 +367,8 @@ // Two dimensional diagonal array with math ops. +#ifndef NO_DIAG_ARRAY + // Element by element MDiagArray by MDiagArray ops. template <class T> @@ -472,6 +476,7 @@ NEG_V; return MDiagArray<T> (result, a.rows (), a.cols ()); } +#endif /* ;;; Local Variables: ***
--- a/liboctave/MArray.h +++ b/liboctave/MArray.h @@ -34,7 +34,10 @@ template <class T> class MArray; template <class T> class MArray2; + +#ifndef NO_DIAG_ARRAY template <class T> class MDiagArray; +#endif // One dimensional array with math ops. @@ -113,7 +116,10 @@ MArray2 (int n, int m, const T& val) : Array2<T> (n, m, val) { } MArray2 (const Array2<T>& a) : Array2<T> (a) { } MArray2 (const MArray2<T>& a) : Array2<T> (a) { } + +#ifndef NO_DIAG_ARRAY MArray2 (const MDiagArray<T>& a); +#endif ~MArray2 (void) { } @@ -160,6 +166,7 @@ // Two dimensional diagonal array with math ops. +#ifndef NO_DIAG_ARRAY template <class T> class MDiagArray : public DiagArray<T> { @@ -171,7 +178,7 @@ MDiagArray (void) : DiagArray<T> () { } MDiagArray (int n) : DiagArray<T> (n) { } - MDiagArray (int n, const T& val) : DiagArray<T> (n, val) { } +// MDiagArray (int n, const T& val) : DiagArray<T> (n, val) { } MDiagArray (int r, int c) : DiagArray<T> (r, c) { } MDiagArray (int r, int c, const T& val) : DiagArray<T> (r, c, val) { } MDiagArray (const DiagArray<T>& a) : DiagArray<T> (a) { } @@ -213,6 +220,7 @@ friend MDiagArray<T> operator - (const MDiagArray<T>& a); }; +#endif #endif
--- a/liboctave/Makefile.in +++ b/liboctave/Makefile.in @@ -22,6 +22,7 @@ mx-defs.h mx-ext.h CColVector.h CDiagMatrix.h CMatrix.h \ CRowVector.h CmplxAEPBAL.h CmplxCHOL.h CmplxDET.h CmplxHESS.h \ CmplxLU.h CmplxQR.h CmplxQRP.h CmplxSCHUR.h CmplxSVD.h EIG.h \ + cMatrix.h \ dColVector.h dDiagMatrix.h dMatrix.h dRowVector.h dbleAEPBAL.h \ dbleCHOL.h dbleDET.h dbleGEPBAL.h dbleHESS.h dbleLU.h dbleQR.h \ dbleQRP.h dbleSCHUR.h dbleSVD.h @@ -35,15 +36,16 @@ TEMPLATE_SRC = Array.cc MArray.cc -TI_SRC = Array-C.cc Array-i.cc Array-d.cc MArray-C.cc MArray-d.cc +TI_SRC = Array-C.cc Array-c.cc Array-i.cc Array-d.cc Array-s.cc \ + MArray-C.cc MArray-c.cc MArray-i.cc MArray-d.cc MArray-s.cc MATRIX_SRC = Array-ext.cc CColVector.cc CDiagMatrix.cc CMatrix.cc \ - CRowVector.cc \ - CmplxAEPBAL.cc CmplxCHOL.cc CmplxDET.cc CmplxHESS.cc CmplxLU.cc \ - CmplxQR.cc CmplxQRP.cc CmplxSCHUR.cc CmplxSVD.cc EIG.cc \ - dColVector.cc dDiagMatrix.cc dMatrix.cc dRowVector.cc \ - dbleAEPBAL.cc dbleCHOL.cc dbleDET.cc dbleGEPBAL.cc dbleHESS.cc \ - dbleLU.cc dbleQR.cc dbleQRP.cc dbleSCHUR.cc dbleSVD.cc + CRowVector.cc CmplxAEPBAL.cc CmplxCHOL.cc CmplxDET.cc \ + CmplxHESS.cc CmplxLU.cc CmplxQR.cc CmplxQRP.cc CmplxSCHUR.cc \ + CmplxSVD.cc EIG.cc cMatrix.cc dColVector.cc dDiagMatrix.cc \ + dMatrix.cc dRowVector.cc dbleAEPBAL.cc dbleCHOL.cc \ + dbleDET.cc dbleGEPBAL.cc dbleHESS.cc dbleLU.cc dbleQR.cc \ + dbleQRP.cc dbleSCHUR.cc dbleSVD.cc SOURCES = Bounds.cc CollocWt.cc DAE.cc FEGrid.cc FSQP.cc LinConst.cc \ LPsolve.cc NLEqn.cc NPSOL.cc ODE.cc QLD.cc QPSOL.cc Quad.cc \
--- a/liboctave/dDiagMatrix.h +++ b/liboctave/dDiagMatrix.h @@ -44,7 +44,7 @@ DiagMatrix (void) : MDiagArray<double> () { } DiagMatrix (int n) : MDiagArray<double> (n) { } - DiagMatrix (int n, double val) : MDiagArray<double> (n, val) { } + DiagMatrix (int n, double val) : MDiagArray<double> (n, n, val) { } DiagMatrix (int r, int c) : MDiagArray<double> (r, c) { } DiagMatrix (int r, int c, double val) : MDiagArray<double> (r, c, val) { } DiagMatrix (const RowVector& a) : MDiagArray<double> (a) { }
--- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -93,6 +93,17 @@ elem (i, i) = a.elem (i, i); } +// XXX FIXME XXX -- could we use a templated mixed-type copy function +// here? + +Matrix::Matrix (const charMatrix& a) + : MArray2<double> (a.rows (), a.cols ()) +{ + for (int i = 0; i < a.rows (); i++) + for (int j = 0; j < a.cols (); j++) + elem (i, j) = a.elem (i, j); +} + int Matrix::operator == (const Matrix& a) const {
--- a/liboctave/dMatrix.h +++ b/liboctave/dMatrix.h @@ -58,6 +58,8 @@ Matrix (const MDiagArray<double>& a) : MArray2<double> (a) { } Matrix (const DiagMatrix& a); + Matrix (const charMatrix& a); + Matrix& operator = (const Matrix& a) { MArray2<double>::operator = (a);
--- a/liboctave/mx-base.h +++ b/liboctave/mx-base.h @@ -26,6 +26,7 @@ // Matrix classes. +#include "cMatrix.h" #include "dMatrix.h" #include "CMatrix.h"
--- a/liboctave/mx-defs.h +++ b/liboctave/mx-defs.h @@ -27,29 +27,43 @@ // Classes we declare. class Matrix; +class ComplexMatrix; +class charMatrix; + class ColumnVector; +class ComplexColumnVector; + class RowVector; +class ComplexRowVector; + class DiagMatrix; -class ComplexMatrix; -class ComplexColumnVector; -class ComplexRowVector; class ComplexDiagMatrix; + class AEPBALANCE; class ComplexAEPBALANCE; + class GEPBALANCE; + class CHOL; class ComplexCHOL; + class DET; class ComplexDET; + class EIG; + class HESS; class ComplexHESS; + class SCHUR; class ComplexSCHUR; + class SVD; class ComplexSVD; + class LU; class ComplexLU; + class QR; class ComplexQR;
--- a/liboctave/mx-inlines.cc +++ b/liboctave/mx-inlines.cc @@ -25,6 +25,17 @@ // But first, some helper functions... +// XXX FIXME XXX -- these need to be done with templates... + +static inline int +equal (const char *x, const char *y, int len) +{ + for (int i = 0; i < len; i++) + if (x[i] != y[i]) + return 0; + return 1; +} + static inline double * add (const double *d, int len, double s) {