# HG changeset patch # User jwe # Date 814077284 0 # Node ID dd7d27461567e09f88c06dae029f9a4721485c27 # Parent 403c60daa8c7c7eb7c12050248614348667a642b [project @ 1995-10-19 04:34:20 by jwe] diff --git a/liboctave/Array-C.cc b/liboctave/Array-C.cc --- a/liboctave/Array-C.cc +++ b/liboctave/Array-C.cc @@ -35,9 +35,15 @@ template void assign (Array&, const Array&); template void assign (Array&, const Array&); +template void assign (Array&, const Array&); +template void assign (Array&, const Array&); +template void assign (Array&, const Array&); template void assign (Array2&, const Array2&); template void assign (Array2&, const Array2&); +template void assign (Array2&, const Array2&); +template void assign (Array2&, const Array2&); +template void assign (Array2&, const Array2&); /* ;;; Local Variables: *** diff --git a/liboctave/Array-d.cc b/liboctave/Array-d.cc --- a/liboctave/Array-d.cc +++ b/liboctave/Array-d.cc @@ -32,8 +32,14 @@ template class DiagArray; template void assign (Array&, const Array&); +template void assign (Array&, const Array&); +template void assign (Array&, const Array&); +template void assign (Array&, const Array&); template void assign (Array2&, const Array2&); +template void assign (Array2&, const Array2&); +template void assign (Array2&, const Array2&); +template void assign (Array2&, const Array2&); /* ;;; Local Variables: *** diff --git a/liboctave/Array-i.cc b/liboctave/Array-i.cc --- 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; template class Array; +template class Array2; -// For now, we only need 1D arrays of integers. -// -// template class Array2; -// template class DiagArray; +#ifndef NO_DIAG_ARRAY +template class DiagArray; +#endif + +template void assign (Array&, const Array&); +template void assign (Array&, const Array&); +template void assign (Array&, const Array&); + +template void assign (Array2&, const Array2&); +template void assign (Array2&, const Array2&); +template void assign (Array2&, const Array2&); /* ;;; Local Variables: *** diff --git a/liboctave/Array-idx.h b/liboctave/Array-idx.h --- a/liboctave/Array-idx.h +++ b/liboctave/Array-idx.h @@ -293,10 +293,15 @@ int len = tmp.length (); - if (pcv_flag) - retval = Array2 (tmp, len, 1); + if (len == 0) + retval = Array2 (0, 0); else - retval = Array2 (tmp, 1, len); + { + if (pcv_flag) + retval = Array2 (tmp, len, 1); + else + retval = Array2 (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 tmp = Array::value (); int len = tmp.length (); - if (result_is_column_vector) - retval = Array2 (tmp, len, 1); + if (len == 0) + retval = Array2 (0, 0); else - retval = Array2 (tmp, 1, len); + { + if (result_is_column_vector) + retval = Array2 (tmp, len, 1); + else + retval = Array2 (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]; diff --git a/liboctave/Array.cc b/liboctave/Array.cc --- 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 T& @@ -640,6 +641,7 @@ if (--old_rep->count <= 0) delete old_rep; } +#endif /* ;;; Local Variables: *** diff --git a/liboctave/Array.h b/liboctave/Array.h --- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -42,7 +42,10 @@ template class Array; template class Array2; template class Array3; + +#ifndef NO_DIAG_ARRAY template class DiagArray; +#endif #ifdef HEAVYWEIGHT_INDEXING #define SET_MAX_INDICES(n) set_max_indices (n) @@ -60,7 +63,10 @@ friend class Array; friend class Array2; friend class Array3; + +#ifndef NO_DIAG_ARRAY friend class DiagArray; +#endif private: @@ -286,6 +292,7 @@ set_max_indices (2); } +#ifndef NO_DIAG_ARRAY Array2 (const DiagArray& a) : Array (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 DiagArray : public Array { @@ -631,6 +640,7 @@ void maybe_delete_elements (idx_vector& i, idx_vector& j); }; +#endif #endif diff --git a/liboctave/CDiagMatrix.h b/liboctave/CDiagMatrix.h --- a/liboctave/CDiagMatrix.h +++ b/liboctave/CDiagMatrix.h @@ -44,7 +44,7 @@ ComplexDiagMatrix (void) : MDiagArray () { } ComplexDiagMatrix (int n) : MDiagArray (n) { } ComplexDiagMatrix (int n, const Complex& val) - : MDiagArray (n, val) { } + : MDiagArray (n, n, val) { } ComplexDiagMatrix (int r, int c) : MDiagArray (r, c) { } ComplexDiagMatrix (int r, int c, const Complex& val) : MDiagArray (r, c, val) { } diff --git a/liboctave/CMatrix.cc b/liboctave/CMatrix.cc --- 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 { diff --git a/liboctave/CMatrix.h b/liboctave/CMatrix.h --- a/liboctave/CMatrix.h +++ b/liboctave/CMatrix.h @@ -58,6 +58,8 @@ ComplexMatrix (const MDiagArray& a) : MArray2 (a) { } ComplexMatrix (const ComplexDiagMatrix& a); + ComplexMatrix (const charMatrix& a); + ComplexMatrix& operator = (const ComplexMatrix& a) { MArray2::operator = (a); diff --git a/liboctave/MArray.cc b/liboctave/MArray.cc --- a/liboctave/MArray.cc +++ b/liboctave/MArray.cc @@ -222,6 +222,7 @@ // Two dimensional array with math ops. +#ifndef NO_DIAG_ARRAY template MArray2::MArray2 (const MDiagArray& a) : Array2 (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 @@ -472,6 +476,7 @@ NEG_V; return MDiagArray (result, a.rows (), a.cols ()); } +#endif /* ;;; Local Variables: *** diff --git a/liboctave/MArray.h b/liboctave/MArray.h --- a/liboctave/MArray.h +++ b/liboctave/MArray.h @@ -34,7 +34,10 @@ template class MArray; template class MArray2; + +#ifndef NO_DIAG_ARRAY template class MDiagArray; +#endif // One dimensional array with math ops. @@ -113,7 +116,10 @@ MArray2 (int n, int m, const T& val) : Array2 (n, m, val) { } MArray2 (const Array2& a) : Array2 (a) { } MArray2 (const MArray2& a) : Array2 (a) { } + +#ifndef NO_DIAG_ARRAY MArray2 (const MDiagArray& a); +#endif ~MArray2 (void) { } @@ -160,6 +166,7 @@ // Two dimensional diagonal array with math ops. +#ifndef NO_DIAG_ARRAY template class MDiagArray : public DiagArray { @@ -171,7 +178,7 @@ MDiagArray (void) : DiagArray () { } MDiagArray (int n) : DiagArray (n) { } - MDiagArray (int n, const T& val) : DiagArray (n, val) { } +// MDiagArray (int n, const T& val) : DiagArray (n, val) { } MDiagArray (int r, int c) : DiagArray (r, c) { } MDiagArray (int r, int c, const T& val) : DiagArray (r, c, val) { } MDiagArray (const DiagArray& a) : DiagArray (a) { } @@ -213,6 +220,7 @@ friend MDiagArray operator - (const MDiagArray& a); }; +#endif #endif diff --git a/liboctave/Makefile.in b/liboctave/Makefile.in --- 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 \ diff --git a/liboctave/dDiagMatrix.h b/liboctave/dDiagMatrix.h --- a/liboctave/dDiagMatrix.h +++ b/liboctave/dDiagMatrix.h @@ -44,7 +44,7 @@ DiagMatrix (void) : MDiagArray () { } DiagMatrix (int n) : MDiagArray (n) { } - DiagMatrix (int n, double val) : MDiagArray (n, val) { } + DiagMatrix (int n, double val) : MDiagArray (n, n, val) { } DiagMatrix (int r, int c) : MDiagArray (r, c) { } DiagMatrix (int r, int c, double val) : MDiagArray (r, c, val) { } DiagMatrix (const RowVector& a) : MDiagArray (a) { } diff --git a/liboctave/dMatrix.cc b/liboctave/dMatrix.cc --- 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 (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 { diff --git a/liboctave/dMatrix.h b/liboctave/dMatrix.h --- a/liboctave/dMatrix.h +++ b/liboctave/dMatrix.h @@ -58,6 +58,8 @@ Matrix (const MDiagArray& a) : MArray2 (a) { } Matrix (const DiagMatrix& a); + Matrix (const charMatrix& a); + Matrix& operator = (const Matrix& a) { MArray2::operator = (a); diff --git a/liboctave/mx-base.h b/liboctave/mx-base.h --- 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" diff --git a/liboctave/mx-defs.h b/liboctave/mx-defs.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; diff --git a/liboctave/mx-inlines.cc b/liboctave/mx-inlines.cc --- 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) {