Changeset 8901 in ntrip
- Timestamp:
- Mar 18, 2020, 11:06:13 AM (5 years ago)
- Location:
- trunk/BNC
- Files:
-
- 4 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/newmat/hholder.cpp
r2013 r8901 335 335 } 336 336 337 // Following previous transformation, 338 // now apply the same orthogonal transformation to (MX & MU) 339 // Need the X Matrix but not the U. 340 // Not optimised for accessing consecutive memory 341 342 void updateQRZ(const Matrix& X, Matrix& MX, Matrix& MU) 343 { 344 REPORT 345 Tracer et("updateQRZ(2)"); 346 int s = X.Ncols(); int n = X.Nrows(); 347 if (n != MX.Nrows()) 348 Throw(ProgramException("Incompatible dimensions",X,MX)); 349 if (s != MU.Nrows()) 350 Throw(ProgramException("Incompatible dimensions",X,MU)); 351 int t = MX.Ncols(); 352 if (t != MU.Ncols()) 353 Throw(ProgramException("Incompatible dimensions",MX,MU)); 354 355 if (s == 0) return; 356 357 const Real* xi0 = X.data(); Real* mx = MX.data(); Real* muj = MU.data(); 358 for (int i=1; i<=s; ++i) 359 { 360 Real sum = 0.0; 361 { 362 const Real* xi=xi0; int k=n; 363 while(k--) { sum += square(*xi); xi+= s;} 364 } 365 Real a0 = sqrt(2.0 - sum); Real* mxj0 = mx; 366 for (int j=1; j<=t; ++j) 367 { 368 Real sum = 0.0; 369 const Real* xi=xi0; Real* mxj=mxj0; int k=n; 370 while(--k) { sum += *xi * *mxj; xi += s; mxj += t; } 371 sum += *xi * *mxj; // last line of loop 372 sum += a0 * *muj; 373 xi=xi0; mxj=mxj0; k=n; 374 while(--k) { *mxj -= sum * *xi; xi += s; mxj += t; } 375 *mxj -= sum * *xi; // last line of loop 376 *muj -= sum * a0; ++mxj0; ++muj; 377 } 378 ++xi0; 379 } 380 } 381 382 383 384 // same thing as updateQRZ(Matrix& X, UpperTriangularMatrix& U) 385 // except that X is upper triangular 386 // contents of X are destroyed - results are in U 387 // assume we can access efficiently by columns 388 // e.g. X and U will fit in cache memory 389 390 void updateQRZ(UpperTriangularMatrix& X, UpperTriangularMatrix& U) 391 { 392 REPORT 393 Tracer et("updateQRZ(3)"); 394 int s = X.Ncols(); 395 if (s != U.Ncols()) 396 Throw(ProgramException("Incompatible dimensions",X,U)); 397 if (s == 0) return; 398 Real* xi0 = X.data(); Real* u = U.data(); 399 for (int i=1; i<=s; ++i) 400 { 401 Real r = *u; Real sum = 0.0; 402 { 403 Real* xi=xi0; int k=i; int l=s; 404 while(k--) { sum += square(*xi); xi+= --l;} 405 } 406 sum = sqrt(sum + square(r)); 407 if (sum == 0.0) { REPORT X.column(i) = 0.0; *u = 0.0; } 408 else 409 { 410 Real frs = fabs(r) + sum; 411 Real a0 = sqrt(frs / sum); Real alpha = a0 / frs; 412 if (r <= 0) { REPORT *u = sum; alpha = -alpha; } 413 else { REPORT *u = -sum; } 414 { 415 Real* xj0=xi0; int k=i; int l=s; 416 while(k--) { *xj0 *= alpha; --l; xj0 += l;} 417 } 418 Real* xj0=xi0; Real* uj=u; 419 for (int j=i+1; j<=s; ++j) 420 { 421 Real sum = 0.0; ++xj0; ++uj; 422 Real* xi=xi0; Real* xj=xj0; int k=i; int l=s; 423 while(k--) { sum += *xi * *xj; --l; xi += l; xj += l; } 424 sum += a0 * *uj; 425 xi=xi0; xj=xj0; k=i; l=s; 426 while(k--) { *xj -= sum * *xi; --l; xi += l; xj += l; } 427 *uj -= sum * a0; 428 } 429 } 430 ++xi0; u += s-i+1; 431 } 432 } 433 434 // Following previous transformation, 435 // now apply the same orthogonal transformation to (MX & MU) 436 // Need the X UpperTriangularMatrix but not the U. 437 438 void updateQRZ(const UpperTriangularMatrix& X, Matrix& MX, Matrix& MU) 439 { 440 REPORT 441 Tracer et("updateQRZ(4)"); 442 int s = X.Ncols(); 443 if (s != MX.Nrows()) 444 Throw(ProgramException("Incompatible dimensions",X,MX)); 445 if (s != MU.Nrows()) 446 Throw(ProgramException("Incompatible dimensions",X,MU)); 447 int t = MX.Ncols(); 448 if (t != MU.Ncols()) 449 Throw(ProgramException("Incompatible dimensions",MX,MU)); 450 if (s == 0) return; 451 452 const Real* xi0 = X.data(); Real* mx = MX.data(); Real* muj = MU.data(); 453 for (int i=1; i<=s; ++i) 454 { 455 Real sum = 0.0; 456 { 457 const Real* xi=xi0; int k=i; int l=s; 458 while(k--) { sum += square(*xi); xi+= --l;} 459 } 460 Real a0 = sqrt(2.0 - sum); Real* mxj0 = mx; 461 for (int j=1; j<=t; ++j) 462 { 463 Real sum = 0.0; 464 const Real* xi=xi0; Real* mxj=mxj0; int k=i; int l=s; 465 while(--k) { sum += *xi * *mxj; --l; xi += l; mxj += t; } 466 sum += *xi * *mxj; // last line of loop 467 sum += a0 * *muj; 468 xi=xi0; mxj=mxj0; k=i; l=s; 469 while(--k) { *mxj -= sum * *xi; --l; xi += l; mxj += t; } 470 *mxj -= sum * *xi; // last line of loop 471 *muj -= sum * a0; ++mxj0; ++muj; 472 } 473 ++xi0; 474 } 475 } 476 477 478 479 480 337 481 // Matrix A's first n columns are orthonormal 338 482 // so A.Columns(1,n).t() * A.Columns(1,n) is the identity matrix. -
trunk/BNC/newmat/include.h
r2013 r8901 1 /// \defgroup rbd_common RBD common library 1 /// \defgroup rbd_common RBD common library 2 2 ///@{ 3 3 … … 44 44 //#define HAS_INT64 // if unsigned _int64 is recognised 45 45 // used by newran03 46 46 47 //#define set_unix_options // set if running UNIX or LINUX 48 47 49 // comment out next line if Exception causes a problem 48 50 #define TypeDefException … … 63 65 #endif 64 66 67 // for Intel C++ for Windows 68 #if defined __ICL 69 #define _STANDARD_ // use standard library 70 #define ios_format_flags ios::fmtflags 71 #endif 72 65 73 // for Microsoft Visual C++ 7 and above (and Intel simulating these) 66 74 #if defined _MSC_VER && _MSC_VER >= 1300 67 75 #define _STANDARD_ // use standard library 76 #endif 77 78 // for Borland Builder C++ 2006 and above 79 #if defined __BCPLUSPLUS__ && __BCPLUSPLUS__ >= 0x0570 80 #define _STANDARD_ // use standard library 81 #define ios_format_flags ios::fmtflags 68 82 #endif 69 83 … … 90 104 #include <fstream> 91 105 #endif 92 ////using namespace std; 93 #define USE_STD_NAMESPACE 106 using namespace std; 94 107 #else 95 108 -
trunk/BNC/newmat/myexcept.cpp
r2013 r8901 26 26 #endif 27 27 28 #ifdef USE_STD_NAMESPACE29 using namespace std;30 #endif31 28 32 29 //#define REG_DEREG // for print out uses of new/delete -
trunk/BNC/newmat/myexcept.h
r2013 r8901 75 75 static void AddTrace(); // insert trace in exception record 76 76 static Tracer* last; // points to Tracer list 77 static void clear() {} // for compatibility 77 78 friend class BaseException; 78 79 }; … … 93 94 static const char* what() { return what_error; } 94 95 // for getting error message 96 static void clear() {} // for compatibility 95 97 }; 96 98 -
trunk/BNC/newmat/newmat.h
r2013 r8901 447 447 class GeneralMatrix : public BaseMatrix // declarable matrix types 448 448 { 449 virtual GeneralMatrix* Image() const; // copy of matrix450 449 protected: 451 450 int tag_val; // shows whether can reuse … … 465 464 void ReverseElements(); // internal reverse of elements 466 465 void ReverseElements(GeneralMatrix*); // reverse order of elements 467 void operator=(Real); // set matrix to constant468 466 Real* GetStore(); // get store or copy 469 467 GeneralMatrix* BorrowStore(GeneralMatrix*, MatrixType); 470 468 // temporarily access store 471 469 void GetMatrix(const GeneralMatrix*); // used by = and initialise 472 void Eq(const BaseMatrix&, MatrixType); // used by =473 void Eq(const GeneralMatrix&); // version with no conversion474 void Eq(const BaseMatrix&, MatrixType, bool);// used by <<475 void Eq2(const BaseMatrix&, MatrixType); // cut down version of Eq476 470 int search(const BaseMatrix*) const; 477 471 virtual GeneralMatrix* Transpose(TransposedMatrix*, MatrixType); … … 484 478 // CleanUp when the data array has already been deleted 485 479 void PlusEqual(const GeneralMatrix& gm); 480 void SP_Equal(const GeneralMatrix& gm); 486 481 void MinusEqual(const GeneralMatrix& gm); 487 482 void PlusEqual(Real f); … … 490 485 public: 491 486 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp); 487 void Eq(const BaseMatrix&, MatrixType); // used by = 488 void Eq(const GeneralMatrix&); // version with no conversion 489 void Eq(const BaseMatrix&, MatrixType, bool);// used by << 490 void Eq2(const BaseMatrix&, MatrixType); // cut down version of Eq 492 491 virtual MatrixType type() const = 0; // type of a matrix 493 492 MatrixType Type() const { return type(); } … … 503 502 const Real* data() const { return store; } 504 503 const Real* const_data() const { return store; } 504 void operator=(Real); // set matrix to constant 505 505 virtual ~GeneralMatrix(); // delete store if set 506 506 void tDelete(); // delete if tag_val permits … … 526 526 void Inject(const GeneralMatrix& GM) { inject(GM); } 527 527 void operator+=(const BaseMatrix&); 528 void SP_eq(const BaseMatrix&); 528 529 void operator-=(const BaseMatrix&); 529 530 void operator*=(const BaseMatrix&); … … 579 580 // ReturnMatrix Reverse() const; // reverse order of elements 580 581 void cleanup(); // to clear store 582 virtual GeneralMatrix* Image() const; // copy of matrix 581 583 582 584 friend class Matrix; … … 625 627 class Matrix : public GeneralMatrix 626 628 { 627 GeneralMatrix* Image() const; // copy of matrix628 629 public: 629 630 Matrix() {} … … 668 669 Real minimum2(int& i, int& j) const; 669 670 void operator+=(const Matrix& M) { PlusEqual(M); } 671 void SP_eq(const Matrix& M) { SP_Equal(M); } 670 672 void operator-=(const Matrix& M) { MinusEqual(M); } 673 void operator+=(const BaseMatrix& M) { GeneralMatrix::operator+=(M); } 674 void SP_eq(const BaseMatrix& M) { GeneralMatrix::SP_eq(M); } 675 void operator-=(const BaseMatrix& M) { GeneralMatrix::operator-=(M); } 671 676 void operator+=(Real f) { GeneralMatrix::Add(f); } 672 677 void operator-=(Real f) { GeneralMatrix::Add(-f); } 673 678 void swap(Matrix& gm) { GeneralMatrix::swap((GeneralMatrix&)gm); } 679 GeneralMatrix* Image() const; // copy of matrix 674 680 friend Real dotproduct(const Matrix& A, const Matrix& B); 675 681 NEW_DELETE(Matrix) … … 679 685 class SquareMatrix : public Matrix 680 686 { 681 GeneralMatrix* Image() const; // copy of matrix682 687 public: 683 688 SquareMatrix() {} … … 701 706 void ReSize(const GeneralMatrix& A) { resize(A); } 702 707 void operator+=(const Matrix& M) { PlusEqual(M); } 708 void SP_eq(const Matrix& M) { SP_Equal(M); } 703 709 void operator-=(const Matrix& M) { MinusEqual(M); } 710 void operator+=(const BaseMatrix& M) { GeneralMatrix::operator+=(M); } 711 void SP_eq(const BaseMatrix& M) { GeneralMatrix::SP_eq(M); } 712 void operator-=(const BaseMatrix& M) { GeneralMatrix::operator-=(M); } 704 713 void operator+=(Real f) { GeneralMatrix::Add(f); } 705 714 void operator-=(Real f) { GeneralMatrix::Add(-f); } 706 715 void swap(SquareMatrix& gm) { GeneralMatrix::swap((GeneralMatrix&)gm); } 716 GeneralMatrix* Image() const; // copy of matrix 707 717 NEW_DELETE(SquareMatrix) 708 718 }; … … 711 721 class nricMatrix : public Matrix 712 722 { 713 GeneralMatrix* Image() const; // copy of matrix714 723 Real** row_pointer; // points to rows 715 724 void MakeRowPointer(); // build rowpointer … … 743 752 void MiniCleanUp(); 744 753 void operator+=(const Matrix& M) { PlusEqual(M); } 754 void SP_eq(const Matrix& M) { SP_Equal(M); } 745 755 void operator-=(const Matrix& M) { MinusEqual(M); } 756 void operator+=(const BaseMatrix& M) { GeneralMatrix::operator+=(M); } 757 void SP_eq(const BaseMatrix& M) { GeneralMatrix::SP_eq(M); } 758 void operator-=(const BaseMatrix& M) { GeneralMatrix::operator-=(M); } 746 759 void operator+=(Real f) { GeneralMatrix::Add(f); } 747 760 void operator-=(Real f) { GeneralMatrix::Add(-f); } 748 761 void swap(nricMatrix& gm); 762 GeneralMatrix* Image() const; // copy of matrix 749 763 NEW_DELETE(nricMatrix) 750 764 }; … … 753 767 class SymmetricMatrix : public GeneralMatrix 754 768 { 755 GeneralMatrix* Image() const; // copy of matrix756 769 public: 757 770 SymmetricMatrix() {} … … 789 802 void ReSize(const GeneralMatrix& A) { resize(A); } 790 803 void operator+=(const SymmetricMatrix& M) { PlusEqual(M); } 804 void SP_eq(const SymmetricMatrix& M) { SP_Equal(M); } 791 805 void operator-=(const SymmetricMatrix& M) { MinusEqual(M); } 806 void operator+=(const BaseMatrix& M) { GeneralMatrix::operator+=(M); } 807 void SP_eq(const BaseMatrix& M) { GeneralMatrix::SP_eq(M); } 808 void operator-=(const BaseMatrix& M) { GeneralMatrix::operator-=(M); } 792 809 void operator+=(Real f) { GeneralMatrix::Add(f); } 793 810 void operator-=(Real f) { GeneralMatrix::Add(-f); } 794 811 void swap(SymmetricMatrix& gm) { GeneralMatrix::swap((GeneralMatrix&)gm); } 812 GeneralMatrix* Image() const; // copy of matrix 795 813 NEW_DELETE(SymmetricMatrix) 796 814 }; … … 799 817 class UpperTriangularMatrix : public GeneralMatrix 800 818 { 801 GeneralMatrix* Image() const; // copy of matrix802 819 public: 803 820 UpperTriangularMatrix() {} … … 837 854 MatrixBandWidth bandwidth() const; 838 855 void operator+=(const UpperTriangularMatrix& M) { PlusEqual(M); } 856 void SP_eq(const UpperTriangularMatrix& M) { SP_Equal(M); } 839 857 void operator-=(const UpperTriangularMatrix& M) { MinusEqual(M); } 858 void operator+=(const BaseMatrix& M) { GeneralMatrix::operator+=(M); } 859 void SP_eq(const BaseMatrix& M) { GeneralMatrix::SP_eq(M); } 860 void operator-=(const BaseMatrix& M) { GeneralMatrix::operator-=(M); } 840 861 void operator+=(Real f) { GeneralMatrix::operator+=(f); } 841 862 void operator-=(Real f) { GeneralMatrix::operator-=(f); } 842 863 void swap(UpperTriangularMatrix& gm) 843 864 { GeneralMatrix::swap((GeneralMatrix&)gm); } 865 GeneralMatrix* Image() const; // copy of matrix 844 866 NEW_DELETE(UpperTriangularMatrix) 845 867 }; … … 848 870 class LowerTriangularMatrix : public GeneralMatrix 849 871 { 850 GeneralMatrix* Image() const; // copy of matrix851 872 public: 852 873 LowerTriangularMatrix() {} … … 885 906 MatrixBandWidth bandwidth() const; 886 907 void operator+=(const LowerTriangularMatrix& M) { PlusEqual(M); } 908 void SP_eq(const LowerTriangularMatrix& M) { SP_Equal(M); } 887 909 void operator-=(const LowerTriangularMatrix& M) { MinusEqual(M); } 910 void operator+=(const BaseMatrix& M) { GeneralMatrix::operator+=(M); } 911 void SP_eq(const BaseMatrix& M) { GeneralMatrix::SP_eq(M); } 912 void operator-=(const BaseMatrix& M) { GeneralMatrix::operator-=(M); } 888 913 void operator+=(Real f) { GeneralMatrix::operator+=(f); } 889 914 void operator-=(Real f) { GeneralMatrix::operator-=(f); } 890 915 void swap(LowerTriangularMatrix& gm) 891 916 { GeneralMatrix::swap((GeneralMatrix&)gm); } 917 GeneralMatrix* Image() const; // copy of matrix 892 918 NEW_DELETE(LowerTriangularMatrix) 893 919 }; … … 896 922 class DiagonalMatrix : public GeneralMatrix 897 923 { 898 GeneralMatrix* Image() const; // copy of matrix899 924 public: 900 925 DiagonalMatrix() {} … … 942 967 // ReturnMatrix Reverse() const; // reverse order of elements 943 968 void operator+=(const DiagonalMatrix& M) { PlusEqual(M); } 969 void SP_eq(const DiagonalMatrix& M) { SP_Equal(M); } 944 970 void operator-=(const DiagonalMatrix& M) { MinusEqual(M); } 971 void operator+=(const BaseMatrix& M) { GeneralMatrix::operator+=(M); } 972 void SP_eq(const BaseMatrix& M) { GeneralMatrix::SP_eq(M); } 973 void operator-=(const BaseMatrix& M) { GeneralMatrix::operator-=(M); } 945 974 void operator+=(Real f) { GeneralMatrix::operator+=(f); } 946 975 void operator-=(Real f) { GeneralMatrix::operator-=(f); } 947 976 void swap(DiagonalMatrix& gm) 948 977 { GeneralMatrix::swap((GeneralMatrix&)gm); } 978 GeneralMatrix* Image() const; // copy of matrix 949 979 NEW_DELETE(DiagonalMatrix) 950 980 }; … … 953 983 class RowVector : public Matrix 954 984 { 955 GeneralMatrix* Image() const; // copy of matrix956 985 public: 957 986 RowVector() { nrows_val = 1; } … … 997 1026 // friend ReturnMatrix GetMatrixRow(Matrix& A, int row); 998 1027 void operator+=(const Matrix& M) { PlusEqual(M); } 1028 void SP_eq(const Matrix& M) { SP_Equal(M); } 999 1029 void operator-=(const Matrix& M) { MinusEqual(M); } 1030 void operator+=(const BaseMatrix& M) { GeneralMatrix::operator+=(M); } 1031 void SP_eq(const BaseMatrix& M) { GeneralMatrix::SP_eq(M); } 1032 void operator-=(const BaseMatrix& M) { GeneralMatrix::operator-=(M); } 1000 1033 void operator+=(Real f) { GeneralMatrix::Add(f); } 1001 1034 void operator-=(Real f) { GeneralMatrix::Add(-f); } 1002 1035 void swap(RowVector& gm) 1003 1036 { GeneralMatrix::swap((GeneralMatrix&)gm); } 1037 GeneralMatrix* Image() const; // copy of matrix 1004 1038 NEW_DELETE(RowVector) 1005 1039 }; … … 1008 1042 class ColumnVector : public Matrix 1009 1043 { 1010 GeneralMatrix* Image() const; // copy of matrix1011 1044 public: 1012 1045 ColumnVector() { ncols_val = 1; } … … 1046 1079 // ReturnMatrix Reverse() const; // reverse order of elements 1047 1080 void operator+=(const Matrix& M) { PlusEqual(M); } 1081 void SP_eq(const Matrix& M) { SP_Equal(M); } 1048 1082 void operator-=(const Matrix& M) { MinusEqual(M); } 1083 void operator+=(const BaseMatrix& M) { GeneralMatrix::operator+=(M); } 1084 void SP_eq(const BaseMatrix& M) { GeneralMatrix::SP_eq(M); } 1085 void operator-=(const BaseMatrix& M) { GeneralMatrix::operator-=(M); } 1049 1086 void operator+=(Real f) { GeneralMatrix::Add(f); } 1050 1087 void operator-=(Real f) { GeneralMatrix::Add(-f); } 1051 1088 void swap(ColumnVector& gm) 1052 1089 { GeneralMatrix::swap((GeneralMatrix&)gm); } 1090 GeneralMatrix* Image() const; // copy of matrix 1053 1091 NEW_DELETE(ColumnVector) 1054 1092 }; … … 1064 1102 void ludcmp(); 1065 1103 void get_aux(CroutMatrix&); // for copying indx[] etc 1066 GeneralMatrix* Image() const; // copy of matrix1067 1104 public: 1068 1105 CroutMatrix(const BaseMatrix&); … … 1088 1125 bool even_exchanges() const { return d; } 1089 1126 void swap(CroutMatrix& gm); 1127 GeneralMatrix* Image() const; // copy of matrix 1090 1128 NEW_DELETE(CroutMatrix) 1091 1129 }; … … 1096 1134 class BandMatrix : public GeneralMatrix 1097 1135 { 1098 GeneralMatrix* Image() const; // copy of matrix1099 1136 protected: 1100 1137 void CornerClear() const; // set unused elements to zero … … 1161 1198 void operator<<(const BaseMatrix& X) { GeneralMatrix::operator<<(X); } 1162 1199 void swap(BandMatrix& gm); 1200 GeneralMatrix* Image() const; // copy of matrix 1163 1201 NEW_DELETE(BandMatrix) 1164 1202 }; … … 1167 1205 class UpperBandMatrix : public BandMatrix 1168 1206 { 1169 GeneralMatrix* Image() const; // copy of matrix1170 1207 public: 1171 1208 UpperBandMatrix() {} … … 1200 1237 void swap(UpperBandMatrix& gm) 1201 1238 { BandMatrix::swap((BandMatrix&)gm); } 1239 GeneralMatrix* Image() const; // copy of matrix 1202 1240 NEW_DELETE(UpperBandMatrix) 1203 1241 }; … … 1206 1244 class LowerBandMatrix : public BandMatrix 1207 1245 { 1208 GeneralMatrix* Image() const; // copy of matrix1209 1246 public: 1210 1247 LowerBandMatrix() {} … … 1239 1276 void swap(LowerBandMatrix& gm) 1240 1277 { BandMatrix::swap((BandMatrix&)gm); } 1278 GeneralMatrix* Image() const; // copy of matrix 1241 1279 NEW_DELETE(LowerBandMatrix) 1242 1280 }; … … 1245 1283 class SymmetricBandMatrix : public GeneralMatrix 1246 1284 { 1247 GeneralMatrix* Image() const; // copy of matrix1248 1285 void CornerClear() const; // set unused elements to zero 1249 1286 short SimpleAddOK(const GeneralMatrix* gm); … … 1300 1337 void operator<<(const BaseMatrix& X) { GeneralMatrix::operator<<(X); } 1301 1338 void swap(SymmetricBandMatrix& gm); 1339 GeneralMatrix* Image() const; // copy of matrix 1302 1340 NEW_DELETE(SymmetricBandMatrix) 1303 1341 }; … … 1314 1352 void ludcmp(); 1315 1353 void get_aux(BandLUMatrix&); // for copying indx[] etc 1316 GeneralMatrix* Image() const; // copy of matrix1317 1354 public: 1318 1355 BandLUMatrix(const BaseMatrix&); … … 1342 1379 MatrixBandWidth bandwidth() const; 1343 1380 void swap(BandLUMatrix& gm); 1381 GeneralMatrix* Image() const; // copy of matrix 1344 1382 NEW_DELETE(BandLUMatrix) 1345 1383 }; … … 1350 1388 class IdentityMatrix : public GeneralMatrix 1351 1389 { 1352 GeneralMatrix* Image() const; // copy of matrix1353 1390 public: 1354 1391 IdentityMatrix() {} … … 1386 1423 void swap(IdentityMatrix& gm) 1387 1424 { GeneralMatrix::swap((GeneralMatrix&)gm); } 1425 GeneralMatrix* Image() const; // copy of matrix 1388 1426 NEW_DELETE(IdentityMatrix) 1389 1427 }; … … 1409 1447 void operator=(const BaseMatrix&); 1410 1448 void operator+=(const BaseMatrix&); 1449 void SP_eq(const BaseMatrix&); 1411 1450 void operator-=(const BaseMatrix&); 1412 1451 void operator*=(const BaseMatrix&); … … 1781 1820 void operator=(const BaseMatrix&); 1782 1821 void operator+=(const BaseMatrix&); 1822 void SP_eq(const BaseMatrix&); 1783 1823 void operator-=(const BaseMatrix&); 1784 1824 void operator=(const GetSubMatrix& m) { operator=((const BaseMatrix&)m); } -
trunk/BNC/newmat/newmat.pro
r5182 r8901 10 10 MOC_DIR = .moc 11 11 12 HEADERS += controlw.h include.h myexcept.h \13 newmatap.h newmat.h newmatio.h \14 newmatrc.h newmatrm.h precisio.h 12 HEADERS += boolean.h controlw.h include.h myexcept.h \ 13 newmatap.h newmat.h newmatio.h newmatnl.h \ 14 newmatrc.h newmatrm.h precisio.h solution.h 15 15 16 SOURCES += bandmat.cpp cholesky.cpp evalue.cpp \17 fft.cpp hholder.cpp jacobi.cpp \18 myexcept.cpp newfft.cpp newmat1.cpp \19 newmat2.cpp newmat3.cpp newmat4.cpp \20 newmat5.cpp newmat6.cpp newmat7.cpp \21 newmat8.cpp newmat9.cpp newmatex.cpp \22 newmatrm.cpp n m_misc.cpp sort.cpp\23 submat.cpp svd.cpp16 SOURCES += bandmat.cpp cholesky.cpp evalue.cpp \ 17 fft.cpp hholder.cpp jacobi.cpp \ 18 myexcept.cpp newfft.cpp newmat1.cpp \ 19 newmat2.cpp newmat3.cpp newmat4.cpp \ 20 newmat5.cpp newmat6.cpp newmat7.cpp \ 21 newmat8.cpp newmat9.cpp newmatex.cpp \ 22 newmatrm.cpp newmatnl.cpp nm_misc.cpp \ 23 sort.cpp submat.cpp svd.cpp solution.cpp 24 24 -
trunk/BNC/newmat/newmat6.cpp
r2013 r8901 495 495 Tracer tr("GeneralMatrix::operator+="); 496 496 // MatrixConversionCheck mcc; 497 Protect(); // so it cannot get deleted 498 // during Evaluate 497 Protect(); // so it cannot get deleted during Evaluate 499 498 GeneralMatrix* gm = ((BaseMatrix&)X).Evaluate(); 500 499 AddedMatrix am(this,gm); 501 500 if (gm==this) Release(2); else Release(); 502 501 Eq2(am,type()); 502 } 503 504 // GeneralMatrix operators 505 506 void GeneralMatrix::SP_eq(const BaseMatrix& X) 507 { 508 REPORT 509 Tracer tr("GeneralMatrix::SP_eq"); 510 // MatrixConversionCheck mcc; 511 Protect(); // so it cannot get deleted during Evaluate 512 GeneralMatrix* gm = ((BaseMatrix&)X).Evaluate(); 513 SPMatrix spm(this,gm); 514 if (gm==this) Release(2); else Release(); 515 Eq2(spm,type()); 503 516 } 504 517 … … 586 599 if (gmx==gm) gm->Release(2); else gm->Release(); 587 600 GeneralMatrix* gmy = am.Evaluate(); 601 if (gmy != gm) { REPORT delete gm; gm = gmy->Image(); } 602 else { REPORT } 603 gm->Protect(); 604 } 605 606 void GenericMatrix::SP_eq(const BaseMatrix& X) 607 { 608 REPORT 609 Tracer tr("GenericMatrix::SP_eq"); 610 if (!gm) Throw(ProgramException("GenericMatrix is null")); 611 gm->Protect(); // so it cannot get deleted during Evaluate 612 GeneralMatrix* gmx = ((BaseMatrix&)X).Evaluate(); 613 SPMatrix spm(gm,gmx); 614 if (gmx==gm) gm->Release(2); else gm->Release(); 615 GeneralMatrix* gmy = spm.Evaluate(); 588 616 if (gmy != gm) { REPORT delete gm; gm = gmy->Image(); } 589 617 else { REPORT } -
trunk/BNC/newmat/newmat7.cpp
r2013 r8901 214 214 } 215 215 216 static void SP(GeneralMatrix* gm, GeneralMatrix* gm2)217 { 218 REPORT 219 Real* s2=gm2->Store(); Real* s=gm->Store(); int i=gm->Storage() >> 2;216 static void SP(GeneralMatrix* gm, const GeneralMatrix* gm2) 217 { 218 REPORT 219 const Real* s2=gm2->Store(); Real* s=gm->Store(); int i=gm->Storage() >> 2; 220 220 while (i--) 221 221 { *s++ *= *s2++; *s++ *= *s2++; *s++ *= *s2++; *s++ *= *s2++; } 222 222 i=gm->Storage() & 3; while (i--) *s++ *= *s2++; 223 } 224 225 void GeneralMatrix::SP_Equal(const GeneralMatrix& gm) 226 { 227 REPORT 228 if (nrows_val != gm.nrows_val || ncols_val != gm.ncols_val) 229 Throw(IncompatibleDimensionsException(*this, gm)); 230 SP(this, &gm); 223 231 } 224 232 -
trunk/BNC/newmat/newmat9.cpp
r2013 r8901 44 44 MatrixRow mr((GeneralMatrix*)&X, LoadOnEntry); 45 45 int w = s.width(); int nr = X.Nrows(); ios_format_flags f = s.flags(); 46 s.setf(ios::fixed, ios::floatfield); 46 if (f & ios::scientific) s.setf(ios::scientific, ios::floatfield); 47 else s.setf(ios::fixed, ios::floatfield); 47 48 for (int i=1; i<=nr; i++) 48 49 { -
trunk/BNC/newmat/newmatap.h
r2013 r8901 26 26 void QRZ(Matrix&, UpperTriangularMatrix&); 27 27 28 void QRZ(const Matrix&, Matrix&, Matrix&); 28 void QRZ(const Matrix&, Matrix&, Matrix&); 29 30 inline void QRZT(Matrix& X, Matrix& Y, LowerTriangularMatrix& L, Matrix& M) 31 { QRZT(X, L); QRZT(X, Y, M); } 32 33 inline void QRZ(Matrix& X, Matrix& Y, UpperTriangularMatrix& U, Matrix& M) 34 { QRZ(X, U); QRZ(X, Y, M); } 29 35 30 36 inline void HHDecompose(Matrix& X, LowerTriangularMatrix& L) … … 38 44 void updateQRZ(Matrix& X, UpperTriangularMatrix& U); 39 45 46 void updateQRZ(const Matrix& X, Matrix& MX, Matrix& MU); 47 48 void updateQRZ(UpperTriangularMatrix& X, UpperTriangularMatrix& U); 49 50 void updateQRZ(const UpperTriangularMatrix& X, Matrix& MX, Matrix& MU); 51 40 52 inline void UpdateQRZT(Matrix& X, LowerTriangularMatrix& L) 41 53 { updateQRZT(X, L); } … … 43 55 inline void UpdateQRZ(Matrix& X, UpperTriangularMatrix& U) 44 56 { updateQRZ(X, U); } 57 58 inline void UpdateQRZ(UpperTriangularMatrix& X, UpperTriangularMatrix& U) 59 { updateQRZ(X, U); } 60 61 inline void UpdateQRZ(const UpperTriangularMatrix& X, Matrix& MX, Matrix& MU) 62 { updateQRZ(X, MX, MU); } 63 64 inline void UpdateQRZ(const Matrix& X, Matrix& MX, Matrix& MU) 65 { updateQRZ(X, MX, MU); } 66 45 67 46 68 // Matrix A's first n columns are orthonormal … … 56 78 57 79 58 // produces the Cholesky decomposition of A + x.t() * x where A = chol.t() * chol59 // and x is a RowVector80 // produces the Cholesky decomposition of A + x.t() * x 81 // where A = chol.t() * chol and x is a RowVector 60 82 void update_Cholesky(UpperTriangularMatrix& chol, RowVector x); 61 83 inline void UpdateCholesky(UpperTriangularMatrix& chol, const RowVector& x) 62 84 { update_Cholesky(chol, x); } 63 85 64 // produces the Cholesky decomposition of A - x.t() * x where A = chol.t() * chol65 // and x is a RowVector86 // produces the Cholesky decomposition of A - x.t() * x 87 // where A = chol.t() * chol and x is a RowVector 66 88 void downdate_Cholesky(UpperTriangularMatrix &chol, RowVector x); 67 89 inline void DowndateCholesky(UpperTriangularMatrix &chol, const RowVector& x) -
trunk/BNC/newmat/newmatio.h
r2013 r8901 16 16 #include "newmat.h" 17 17 18 #ifdef USE_STD_NAMESPACE19 using namespace std; 18 #ifdef use_namespace 19 namespace NEWMAT { 20 20 #endif 21 22 21 23 22 24 // **************************** input/output *****************************/ -
trunk/BNC/newmat/precisio.h
r2013 r8901 25 25 #endif 26 26 27 using namespace std; 28 27 29 /// Floating point precision. 28 30 class FloatingPointPrecision … … 30 32 public: 31 33 static int Dig() // number of decimal digits or precision 32 { return std::numeric_limits<Real>::digits10 ; }34 { return numeric_limits<Real>::digits10 ; } 33 35 34 36 static Real Epsilon() // smallest number such that 1+Eps!=Eps 35 { return std::numeric_limits<Real>::epsilon(); }37 { return numeric_limits<Real>::epsilon(); } 36 38 37 39 static int Mantissa() // bits in mantisa 38 { return std::numeric_limits<Real>::digits; }40 { return numeric_limits<Real>::digits; } 39 41 40 42 static Real Maximum() // maximum value 41 { return std::numeric_limits<Real>::max(); }43 { return numeric_limits<Real>::max(); } 42 44 43 45 static int MaximumDecimalExponent() // maximum decimal exponent 44 { return std::numeric_limits<Real>::max_exponent10; }46 { return numeric_limits<Real>::max_exponent10; } 45 47 46 48 static int MaximumExponent() // maximum binary exponent 47 { return std::numeric_limits<Real>::max_exponent; }49 { return numeric_limits<Real>::max_exponent; } 48 50 49 51 static Real LnMaximum() // natural log of maximum … … 51 53 52 54 static Real Minimum() // minimum positive value 53 { return std::numeric_limits<Real>::min(); }55 { return numeric_limits<Real>::min(); } 54 56 55 57 static int MinimumDecimalExponent() // minimum decimal exponent 56 { return std::numeric_limits<Real>::min_exponent10; }58 { return numeric_limits<Real>::min_exponent10; } 57 59 58 60 static int MinimumExponent() // minimum binary exponent 59 { return std::numeric_limits<Real>::min_exponent; }61 { return numeric_limits<Real>::min_exponent; } 60 62 61 63 static Real LnMinimum() // natural log of minimum … … 63 65 64 66 static int Radix() // exponent radix 65 { return std::numeric_limits<Real>::radix; }67 { return numeric_limits<Real>::radix; } 66 68 67 69 static int Rounds() // addition rounding (1 = does round) 68 70 { 69 return std::numeric_limits<Real>::round_style ==70 std::round_to_nearest ? 1 : 0;71 return numeric_limits<Real>::round_style == 72 round_to_nearest ? 1 : 0; 71 73 } 72 74 -
trunk/BNC/newmat/submat.cpp
r2013 r8901 257 257 if (row_number != gmx->Nrows() || col_number != gmx->Ncols()) 258 258 Throw(IncompatibleDimensionsException()); 259 if (gm->type().is_symmetric() && 260 ( ! gmx->type().is_symmetric() || row_skip != col_skip) ) 261 Throw(ProgramException("Illegal operation on symmetric")); 259 262 MatrixRow mrx(gmx, LoadOnEntry); 260 263 MatrixRow mr(gm, LoadOnEntry+StoreOnExit+DirectPart, row_skip); … … 277 280 } 278 281 279 void GetSubMatrix:: operator-=(const BaseMatrix& bmx)280 { 281 REPORT 282 Tracer tr("SubMatrix( -=)"); GeneralMatrix* gmx = 0;282 void GetSubMatrix::SP_eq(const BaseMatrix& bmx) 283 { 284 REPORT 285 Tracer tr("SubMatrix(SP_eq)"); GeneralMatrix* gmx = 0; 283 286 // MatrixConversionCheck mcc; // Check for loss of info 284 287 Try … … 287 290 if (row_number != gmx->Nrows() || col_number != gmx->Ncols()) 288 291 Throw(IncompatibleDimensionsException()); 292 if (gm->type().is_symmetric() && 293 ( ! gmx->type().is_symmetric() || row_skip != col_skip) ) 294 Throw(ProgramException("Illegal operation on symmetric")); 295 MatrixRow mrx(gmx, LoadOnEntry); 296 MatrixRow mr(gm, LoadOnEntry+StoreOnExit+DirectPart, row_skip); 297 // do need LoadOnEntry 298 MatrixRowCol sub; int i = row_number; 299 while (i--) 300 { 301 mr.SubRowCol(sub, col_skip, col_number); // put values in sub 302 sub.Multiply(mrx); mr.Next(); mrx.Next(); 303 } 304 gmx->tDelete(); 305 } 306 307 CatchAll 308 { 309 if (gmx) gmx->tDelete(); 310 ReThrow; 311 } 312 } 313 314 void GetSubMatrix::operator-=(const BaseMatrix& bmx) 315 { 316 REPORT 317 Tracer tr("SubMatrix(-=)"); GeneralMatrix* gmx = 0; 318 // MatrixConversionCheck mcc; // Check for loss of info 319 Try 320 { 321 SetUpLHS(); gmx = ((BaseMatrix&)bmx).Evaluate(); 322 if (row_number != gmx->Nrows() || col_number != gmx->Ncols()) 323 Throw(IncompatibleDimensionsException()); 324 if (gm->type().is_symmetric() && 325 ( ! gmx->type().is_symmetric() || row_skip != col_skip) ) 326 Throw(ProgramException("Illegal operation on symmetric")); 289 327 MatrixRow mrx(gmx, LoadOnEntry); 290 328 MatrixRow mr(gm, LoadOnEntry+StoreOnExit+DirectPart, row_skip); -
trunk/BNC/src/PPP_SSR_I/pppFilter.cpp
r8253 r8901 332 332 xRec(3) = z(); 333 333 334 double rho0 = (satData->xx - xRec). norm_Frobenius();334 double rho0 = (satData->xx - xRec).NormFrobenius(); 335 335 double dPhi = t_CST::omega * rho0 / t_CST::c; 336 336 … … 341 341 xRec += _tides->displacement(_time, xRec); 342 342 343 satData->rho = (satData->xx - xRec). norm_Frobenius();343 satData->rho = (satData->xx - xRec).NormFrobenius(); 344 344 345 345 double tropDelay = delay_saast(satData->eleSat) + … … 796 796 // -------------------------------------- 797 797 ColumnVector rho = rRec - rSat; 798 rho /= rho. norm_Frobenius();798 rho /= rho.NormFrobenius(); 799 799 800 800 // GPS Satellite unit Vectors sz, sy, sx 801 801 // ------------------------------------- 802 ColumnVector sz = -rSat / rSat. norm_Frobenius();802 ColumnVector sz = -rSat / rSat.NormFrobenius(); 803 803 804 804 ColumnVector xSun = t_astro::Sun(Mjd); 805 xSun /= xSun. norm_Frobenius();805 xSun /= xSun.NormFrobenius(); 806 806 807 807 ColumnVector sy = crossproduct(sz, xSun); … … 839 839 // ---------------- 840 840 double alpha = DotProduct(dipSat,dipRec) / 841 (dipSat. norm_Frobenius() * dipRec.norm_Frobenius());841 (dipSat.NormFrobenius() * dipRec.NormFrobenius()); 842 842 843 843 if (alpha > 1.0) alpha = 1.0; … … 861 861 Tracer tracer("t_pppFilter::cmpEle"); 862 862 ColumnVector rr = satData->xx - _xcBanc.Rows(1,3); 863 double rho = rr. norm_Frobenius();863 double rho = rr.NormFrobenius(); 864 864 865 865 double neu[3]; -
trunk/BNC/src/combination/bnccomb.cpp
r8736 r8901 1141 1141 } 1142 1142 else { 1143 double normMax = maxDiff[prn]->_diffRao. norm_Frobenius();1144 double norm = corr->_diffRao. norm_Frobenius();1143 double normMax = maxDiff[prn]->_diffRao.NormFrobenius(); 1144 double norm = corr->_diffRao.NormFrobenius(); 1145 1145 if (norm > normMax) { 1146 1146 maxDiff[prn] = corr; … … 1165 1165 } 1166 1166 else if (corr == maxDiff[prn]) { 1167 double norm = corr->_diffRao. norm_Frobenius();1167 double norm = corr->_diffRao.NormFrobenius(); 1168 1168 if (norm > MAX_DISPLACEMENT) { 1169 1169 out << _resTime.datestr().c_str() << " " -
trunk/BNC/src/rinex/reqcanalyze.cpp
r8756 r8901 278 278 ++nSatUsed; 279 279 ColumnVector dx = xSat.Rows(1,3) - xyzSta; 280 double rho = dx. norm_Frobenius();280 double rho = dx.NormFrobenius(); 281 281 AA(nSatUsed,1) = dx(1) / rho; 282 282 AA(nSatUsed,2) = dx(2) / rho;
Note:
See TracChangeset
for help on using the changeset viewer.