Changeset 37f35e3 in tol
- Timestamp:
- May 10, 2010, 12:49:21 PM (16 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- c2d5affd
- Parents:
- 00672de
- File:
-
- 1 edited
-
tol_pkg/BysVecLinReg/Multivariant.tol (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol_pkg/BysVecLinReg/Multivariant.tol
r00672de r37f35e3 73 73 VMatrix _.VxIm.Lf = Rand(0,0,0,0); 74 74 //Choleski decomposition of VxIm as sparse explicit((d*m)x(d*m)) 75 VMatrix _.VxIm.L s= Rand(0,0,0,0);75 VMatrix _.VxIm.Le = Rand(0,0,0,0); 76 76 77 77 //////////////////////////////////////////////////////////////////////////// 78 VMatrix vmatrix2vec(VMatrix M)78 Static VMatrix vmatrix2vec(VMatrix M) 79 79 //////////////////////////////////////////////////////////////////////////// 80 80 { … … 84 84 85 85 //////////////////////////////////////////////////////////////////////////// 86 VMatrix vec2vmatrix(VMatrix vec, VMatrix M)86 Static VMatrix vec2vmatrix(VMatrix vec, VMatrix M) 87 87 //////////////////////////////////////////////////////////////////////////// 88 88 { 89 89 Matrix Mt = VMat2Mat(M,True); 90 Mat2VMat(DeepCopy([[Mt]], vec)[1])90 Mat2VMat(DeepCopy([[Mt]],VMat2Mat(vec))[1],True) 91 91 }; 92 92 … … 177 177 VMatrix _.X.Le := CholeskiSolve(_.X.Lf, 178 178 Convert(_.X.Lf, "Cholmod.R.Sparse"),"P"); 179 VMatrix _.X.Li := CholeskiSolve(_.X.Lf,Eye(_.m),"PtL LtP");179 VMatrix _.X.Li := CholeskiSolve(_.X.Lf,Eye(_.m),"PtL"); 180 180 VMatrix _.IdxXL := KroneckerProduct(Eye(_.d),_.X.Le); 181 181 VMatrix _.IdxXLi := KroneckerProduct(Eye(_.d),_.X.Li); … … 194 194 VMatrix XYt =_.X*Tra(_.Y); 195 195 VMatrix _.nu:=Tra(CholeskiSolve(_.X.Lf,XYt,"PtLLtP")); 196 VMatrix _.nuXYt = _.nu*XYt;197 VMatrix _.vec.nu:= vmatrix2vec(_.nu);196 VMatrix _.nuXYt := _.nu*XYt; 197 VMatrix _.vec.nu:=@Multivariant::vmatrix2vec(_.nu); 198 198 True 199 199 }) … … 212 212 { 213 213 Real _.alpha := alpha; 214 VMatrix _.Sy.x = _.YYt - _.nuXYt/(1+_.alpha);214 VMatrix _.Sy.x := _.YYt - _.nuXYt/(1+_.alpha); 215 215 True 216 216 }) … … 225 225 VMatrix _.V := Copy(V); 226 226 VMatrix _.VxIm := KroneckerProduct(_.V, Eye(_.m)); 227 VMatrix _.VxIm.Lf := Choleski Solve(_.VxIm,"X");227 VMatrix _.VxIm.Lf := CholeskiFactor(_.VxIm,"X"); 228 228 VMatrix _.VxIm.Le := CholeskiSolve(_.VxIm.Lf, 229 229 Convert(_.VxIm.Lf, "Cholmod.R.Sparse"),"P"); 230 VMatrix _.VxIm.Lf := Choleski Solve(_.VxIm,"X");230 VMatrix _.VxIm.Lf := CholeskiFactor(_.VxIm,"X"); 231 231 VMatrix _.VxIm.Le := CholeskiSolve(_.VxIm.Lf, 232 232 Convert(_.VxIm.Lf, "Cholmod.R.Sparse"),"P"); … … 255 255 256 256 //////////////////////////////////////////////////////////////////////////// 257 VMatrix gibbs.draw.vec.A(Real numSim) 258 //////////////////////////////////////////////////////////////////////////// 259 { 260 VMatrix e = Gaussian(_.d*_.m,1,0,1); 261 VMatrix e.1 = _.VxIm.Le*e; 262 VMatrix e.2 = Tra(Tra(e.1)*_.IdxXLi); 263 VMatrix _.vec.A := (_.vec.nu + e.2)/(1+_.alpha); 264 _.vec.A 265 }; 266 267 //////////////////////////////////////////////////////////////////////////// 257 268 VMatrix gibbs.draw.A(Real numSim) 258 269 //////////////////////////////////////////////////////////////////////////// 259 270 { 260 VMatrix e = Gaussian(_.d*_.m_,1,0,1); 261 VMatrix e.1 = _.VxIm.Le*e; 262 VMatrix e.2 = _.IdxXLi*e.1; 263 VMatrix _.vec.A := (_.vec.nu + e.2)/(1+_.alpha); 264 VMatrix _.A := vec2vmatrix(_.vec.a); 271 VMatrix gibbs.draw.vec.A(numSim); 272 VMatrix _.A := @Multivariant::vec2vmatrix(_.vec.a); 265 273 Copy(_.A) 266 };267 268 ////////////////////////////////////////////////////////////////////////////269 VMatrix gibbs.draw(Real numSim)270 ////////////////////////////////////////////////////////////////////////////271 {272 _.vec.A273 274 } 275 274 276 } 275 277
Note: See TracChangeset
for help on using the changeset viewer.
