Changeset 53456bc in tol
- Timestamp:
- May 17, 2015, 9:07:07 AM (11 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 1e43dec
- Parents:
- 2789f1d
- Location:
- tol/btol
- Files:
-
- 5 edited
-
matrix_type/matgra.cpp (modified) (1 diff)
-
real_type/datgrav.cpp (modified) (8 diffs)
-
vmatrix_type/tol_bvmat.h (modified) (2 diffs)
-
vmatrix_type/vmat_chol.cpp (modified) (3 diffs)
-
vmatrix_type/vmatgra.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tol/btol/matrix_type/matgra.cpp
r2789f1d r53456bc 4662 4662 { 4663 4663 contens_(i,0)=i+1; 4664 contens_(i,1)= acf(i);4664 contens_(i,1)=pacf(i); 4665 4665 contens_(i,2)=sigma; 4666 4666 } -
tol/btol/real_type/datgrav.cpp
r2789f1d r53456bc 809 809 if(g->Grammar()==GraText()) 810 810 { 811 const BText& gt = Text(g); 811 812 graOpt.AllocBuffer(1); 812 graOpt[0] = FindGrammar( Text(g));813 graOpt[0] = FindGrammar(gt); 813 814 } 814 815 else if(g->Grammar()==GraSet()) … … 889 890 } 890 891 892 893 //-------------------------------------------------------------------- 894 bool DestroyIdNeeded(BSyntaxObject*& result, int nObj0) 895 //-------------------------------------------------------------------- 896 { 897 if(result) 898 { 899 return(false); 900 } 901 { 902 int nObj1 = AliveObjects(); 903 if(nObj1>nObj0) 904 { 905 DESTROY(result); 906 result = NULL; 907 return(true); 908 } 909 else 910 { 911 return(false); 912 } 913 } 914 }; 915 891 916 //-------------------------------------------------------------------- 892 917 DeclareContensClass(BDat, BDatTemporary, BDatObjectExist); … … 901 926 { 902 927 BSyntaxObject* g = Arg(1); 903 const BText& name = Text(Arg(2));928 const BText& name = Text(Arg(2)); 904 929 BArray<BSyntaxObject*> graOpt; 905 930 int i; … … 909 934 contens_ = false; 910 935 if(!GetGrammarOptions(g, graOpt)) { return; } 936 int nObj0 = AliveObjects(); 911 937 for(i=0; !result && (i<graOpt.Size()); i++) 912 938 { … … 930 956 if(result && Set(result).Struct()!=found) 931 957 { 932 result = NULL;958 DestroyIdNeeded(result, nObj0); 933 959 } 934 960 } … … 942 968 if(!nb.IsInstanceOf((BClass*)found)) 943 969 { 944 result = NULL;970 DestroyIdNeeded(result, nObj0); 945 971 } 946 972 } … … 948 974 } 949 975 contens_ = result!=NULL; 976 DestroyIdNeeded(result, nObj0); 950 977 } 951 978 … … 2155 2182 { 2156 2183 contens_ = Dat(Arg(1)); 2157 BSys::SleepMilliSeconds(( BInt)contens_.Value()*1000);2184 BSys::SleepMilliSeconds((int)(contens_.Value()*1000.0)); 2158 2185 } 2159 2186 -
tol/btol/vmatrix_type/tol_bvmat.h
r2789f1d r53456bc 742 742 BVMat CholeskiSolve(const BVMat& B, const BText& sys)const; 743 743 BVMat CholeskiInv ()const; 744 int CholeskiUpdate (const BVMat& C_, bool upDown); 745 int CholeskiAddRow (const BVMat& R_, int rowPos); 746 int CholeskiDelRow (const BVMat& R_, int rowPos); 744 747 745 748 static int CholeskiFactor(const BVMat& X, BVMat& L, … … 755 758 static int CholeskiInv (const BVMat& X, BVMat& Xi); 756 759 static int CholeskiMinRes(const BVMat& X, const BVMat& b, BVMat& a); 760 static int CholeskiUpdate (const BVMat& L, const BVMat& C_, bool upDown); 761 static int CholeskiAddRow (const BVMat& L, const BVMat& R_, int rowPos); 762 static int CholeskiDelRow (const BVMat& L, const BVMat& R_, int rowPos); 757 763 758 764 private: -
tol/btol/vmatrix_type/vmat_chol.cpp
r2789f1d r53456bc 76 76 res = cholmod_factorize(X.s_.chlmRsparse_,L.s_.chlmRfactor_,common_); 77 77 TRACE_CHOLMOD_ALLOCATE("Cholmod.R.Factor",X.s_.chlmRsparse_) 78 isNotPosDef = (L.s_.chlmRfactor_->minor<L.s_.chlmRfactor_->n); 78 79 isNotPosDef = (common_->status == CHOLMOD_NOT_POSDEF)|| 80 (L.s_.chlmRfactor_->minor<L.s_.chlmRfactor_->n); 79 81 cholmod_change_factor 80 82 ( … … 739 741 740 742 741 742 743 //////////////////////////////////////////////////////////////////////////////// 743 744 BVMat BVMat::CholeskiSolve(const BVMat& B, ECholSolSys sys) const … … 810 811 return(0); 811 812 }; 813 814 815 //////////////////////////////////////////////////////////////////////////////// 816 int BVMat::CholeskiUpdate (const BVMat& L, const BVMat& C_, bool upDown) 817 //////////////////////////////////////////////////////////////////////////////// 818 { 819 if(!L .CheckDefined("CholeskiUpdate")) { return(-1); } 820 if(!C_.CheckDefined("CholeskiUpdate")) { return(-1); } 821 int result = 0; 822 BVMat *C__=NULL; 823 if(L.code_==ESC_chlmRfactor) 824 { 825 convertIfNeeded_all2cRs(C_,C__,"CholeskiUpdate"); 826 } 827 else 828 { 829 err_invalid_subtype("CholeskiUpdate",L); 830 result = -2; 831 return(result); 832 } 833 BVMat &C = *C__; 834 cholmod_factor* l = L.s_.chlmRfactor_; 835 cholmod_sparse* c = cholmod_submatrix( 836 C.s_.chlmRsparse_, (int*)l->Perm, l->n, NULL, -1, 1, 1, common_); 837 result = cholmod_updown(upDown, c, l, common_); 838 bool isNotPosDef = (common_->status == CHOLMOD_NOT_POSDEF)|| 839 (L.s_.chlmRfactor_->minor<L.s_.chlmRfactor_->n); 840 if(isNotPosDef) 841 { 842 result == -1; 843 err_cannot_apply("CholeskiUpdate","",L); 844 } 845 else 846 { 847 CholmodFree_sparse(&c,common_); 848 849 } 850 if(C__!=&C_) { delete C__; } 851 return(result); 852 } 853 854 855 //////////////////////////////////////////////////////////////////////////////// 856 int BVMat::CholeskiUpdate (const BVMat& C_, bool upDown) 857 //Matrix algebra operator 858 //////////////////////////////////////////////////////////////////////////////// 859 { 860 return(CholeskiUpdate(*this,C_,upDown)); 861 }; 862 863 864 //////////////////////////////////////////////////////////////////////////////// 865 int BVMat::CholeskiAddRow (const BVMat& L, const BVMat& R_, int rowPos) 866 //////////////////////////////////////////////////////////////////////////////// 867 { 868 if(!L .CheckDefined("CholeskiAddRow")) { return(-1); } 869 if(!R_.CheckDefined("CholeskiAddRow")) { return(-1); } 870 int result = 0; 871 BVMat *R__=NULL; 872 if(L.code_==ESC_chlmRfactor) 873 { 874 convertIfNeeded_all2cRs(R_,R__,"CholeskiAddRow"); 875 } 876 else 877 { 878 err_invalid_subtype("CholeskiAddRow",L); 879 result = -2; 880 return(result); 881 } 882 BVMat &R = *R__; 883 result = cholmod_rowadd(rowPos, R.s_.chlmRsparse_, L.s_.chlmRfactor_, common_); 884 if(R__!=&R_) { delete R__; } 885 return(result); 886 } 887 888 889 //////////////////////////////////////////////////////////////////////////////// 890 int BVMat::CholeskiAddRow (const BVMat& R_, int rowPos) 891 //Matrix algebra operator 892 //////////////////////////////////////////////////////////////////////////////// 893 { 894 return(CholeskiAddRow(*this,R_,rowPos)); 895 }; 896 897 //////////////////////////////////////////////////////////////////////////////// 898 int BVMat::CholeskiDelRow (const BVMat& L, const BVMat& R_, int rowPos) 899 //////////////////////////////////////////////////////////////////////////////// 900 { 901 if(!L .CheckDefined("CholeskiDelRow")) { return(-1); } 902 if(!R_.CheckDefined("CholeskiDelRow")) { return(-1); } 903 int result = 0; 904 BVMat *R__=NULL; 905 if(L.code_==ESC_chlmRfactor) 906 { 907 convertIfNeeded_all2cRs(R_,R__,"CholeskiDelRow"); 908 } 909 else 910 { 911 err_invalid_subtype("CholeskiDelRow",L); 912 result = -2; 913 return(result); 914 } 915 BVMat &R = *R__; 916 result = cholmod_rowdel(rowPos, R.s_.chlmRsparse_, L.s_.chlmRfactor_, common_); 917 if(R__!=&R_) { delete R__; } 918 return(result); 919 } 920 921 922 //////////////////////////////////////////////////////////////////////////////// 923 int BVMat::CholeskiDelRow (const BVMat& R_, int rowPos) 924 //Matrix algebra operator 925 //////////////////////////////////////////////////////////////////////////////// 926 { 927 return(CholeskiDelRow(*this,R_,rowPos)); 928 }; 929 930 931 -
tol/btol/vmatrix_type/vmatgra.cpp
r2789f1d r53456bc 2333 2333 2334 2334 2335 //-------------------------------------------------------------------- 2336 DeclareContensClass(BDat, BDatTemporary, BDatCholeskiUpdate); 2337 DefExtOpr(1, BDatCholeskiUpdate, "CholeskiUpdate", 3, 3, 2338 "VMatrix VMatrix Real", 2339 "(VMatrix L, VMatrix C, Real upDown)", 2340 "Updates a LL' Cholesky factorization computing LL'+CC' if upDown " 2341 "is true or LL'-CC' in other case.", 2342 BOperClassify::MatrixAlgebra_); 2343 //-------------------------------------------------------------------- 2344 void BDatCholeskiUpdate::CalcContens() 2345 //-------------------------------------------------------------------- 2346 { 2347 contens_ = BVMat::CholeskiUpdate(VMat(Arg(1)), VMat(Arg(2)), (bool)Real(Arg(3))); 2348 } 2349 2350 2351 //-------------------------------------------------------------------- 2352 DeclareContensClass(BDat, BDatTemporary, BDatCholeskiAddRow); 2353 DefExtOpr(1, BDatCholeskiAddRow, "CholeskiAddRow", 3, 3, 2354 "VMatrix VMatrix Real", 2355 "(VMatrix factor, VMatrix rowData, Real rowPos)", 2356 "Adds a new row to a Cholesky factorization.", 2357 BOperClassify::MatrixAlgebra_); 2358 //-------------------------------------------------------------------- 2359 void BDatCholeskiAddRow::CalcContens() 2360 //-------------------------------------------------------------------- 2361 { 2362 contens_ = BVMat::CholeskiAddRow(VMat(Arg(1)), VMat(Arg(2)), (int)Real(Arg(3))); 2363 } 2364 2365 //-------------------------------------------------------------------- 2366 DeclareContensClass(BDat, BDatTemporary, BDatCholeskiDelRow); 2367 DefExtOpr(1, BDatCholeskiDelRow, "CholeskiDelRow", 3, 3, 2368 "VMatrix VMatrix Real", 2369 "(VMatrix factor, VMatrix rowData, Real rowPos)", 2370 "Deletes a row to a Cholesky factorization.", 2371 BOperClassify::MatrixAlgebra_); 2372 //-------------------------------------------------------------------- 2373 void BDatCholeskiDelRow::CalcContens() 2374 //-------------------------------------------------------------------- 2375 { 2376 contens_ = BVMat::CholeskiDelRow(VMat(Arg(1)), VMat(Arg(2)), (int)Real(Arg(3))); 2377 } 2378 2335 2379 /*------------------------------------------------------------------------------ 2336 2380 vmat_stats.cpp: Statistics methods
Note: See TracChangeset
for help on using the changeset viewer.
