Changeset 23d43bc in tol
- Timestamp:
- Nov 9, 2009, 10:19:41 AM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 3affc27
- Parents:
- 883e960
- Location:
- tol/btol/vmatrix_type
- Files:
-
- 4 edited
-
tol_bvmat.h (modified) (1 diff)
-
tol_bvmat_impl.h (modified) (1 diff)
-
vmat_convert.cpp (modified) (1 diff)
-
vmatgra.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/btol/vmatrix_type/tol_bvmat.h
r883e960 r23d43bc 426 426 double minSparse = 0.5, 427 427 double drop = 0.0); 428 void DMat2tripletUnique(const BMatrix<double>& d, int nrow, int columns); 428 429 void DMat2triplet(const BMatrix<double>& d, int nrow, int columns); 429 430 void DMat2triplet(const BMatrix<double>& d, int nrow, int columns, -
tol/btol/vmatrix_type/tol_bvmat_impl.h
r883e960 r23d43bc 32 32 #include "cholmod.h" 33 33 #pragma pack(4) 34 typedef hash_map_by_BIntPair<double>::sparse_ BHashPairs; 34 typedef hash_map_by_BIntPair<double>::sparse_ BHashDoubleByIntPair; 35 typedef hash_map_by_BIntPair<bool>::sparse_ BHashBoolByIntPair; 35 36 36 37 BEGIN_DECLS -
tol/btol/vmatrix_type/vmat_convert.cpp
r883e960 r23d43bc 457 457 } 458 458 }; 459 460 461 //////////////////////////////////////////////////////////////////////////////// 462 void BVMat::DMat2tripletUnique(const BMatrix<double>& ijx, int nrow, int ncol) 463 //Importing method 464 //Converts a row major BMatrix<double> to a column major cholmod dense matrix 465 //////////////////////////////////////////////////////////////////////////////// 466 { 467 BHashBoolByIntPair hashPairs; 468 BIntPair p; 469 double x; 470 static BText fName = "TripletUnique"; 471 Delete(); 472 int h, k, n = ijx.Rows(); 473 code_ = ESC_chlmRtriplet; 474 s_.chlmRtriplet_ = cholmod_allocate_triplet 475 (nrow,ncol,n,0,CHOLMOD_REAL,common_); 476 int* r_ = (int*) s_.chlmRtriplet_->i; 477 int* c_ = (int*) s_.chlmRtriplet_->j; 478 double* x_ = (double*)s_.chlmRtriplet_->x; 479 bool ok = true; 480 k=-1; 481 for(h=0; h<n; h++) 482 { 483 p.r_ = (int)ijx(h,0)-1; 484 p.c_ = (int)ijx(h,1)-1; 485 x = ijx(h,2); 486 if(x==0.0) { continue; } 487 BHashBoolByIntPair::const_iterator fc = hashPairs.find(p); 488 if(fc!=hashPairs.end()) { continue; } 489 hashPairs[p] = true; 490 k++; 491 r_[k] = p.r_; 492 c_[k] = p.c_; 493 x_[k] = x; 494 495 if((r_[k]<0)||(r_[k]>=nrow)) 496 { 497 err_cannot_apply(fName, 498 BText("Row index ")+(r_[k]+1)+" out of range 1..."+(nrow+1), 499 *this); 500 ok = false; 501 break; 502 } 503 else if((c_[k]<0)||(c_[k]>=ncol)) 504 { 505 err_cannot_apply(fName, 506 BText("Columns index ")+(c_[k]+1)+" out of range 1..."+(ncol+1), 507 *this); 508 ok = false; 509 break; 510 } 511 s_.chlmRtriplet_->nnz++; 512 } 513 if(!ok) { Delete(); } 514 }; 515 459 516 460 517 -
tol/btol/vmatrix_type/vmatgra.cpp
r883e960 r23d43bc 485 485 } 486 486 487 488 487 //-------------------------------------------------------------------- 489 488 DeclareContensClass(BVMat, BVMatTemporary, BVMatTriplet); … … 500 499 "It's posible to remap row and column indexes of cells by specifying it " 501 500 "with rowIdx and colIdx arguments, that must be row or column matrices " 502 "of integer numbers.", 501 "of integer numbers." 502 "CAUTION: Repeated cells will be summed!. To avoid this use " 503 "TripletUnique" , 503 504 "Construye una VMatrix Cholmod.R.Triplet T con la sdimensiones dadas a " 504 505 "partir de una lista de tripletas ijx que pueden expresarse bien " … … 509 510 "Es posible reubicar los índices de las filas y columnas de las celdas " 510 511 "especificándolo con los argumentos rowIdx y colIdx, que deben ser " 511 "matrices fila o columna de números enteros."), 512 "matrices fila o columna de números enteros.\n" 513 "CUIDADO: ¡Las celdas repetidas serán sumadas! Para evitarlo use " 514 "TripletUnique"), 512 515 BOperClassify::MatrixAlgebra_); 513 516 //-------------------------------------------------------------------- … … 612 615 613 616 //-------------------------------------------------------------------- 617 DeclareContensClass(BVMat, BVMatTemporary, BVMatTripletUnique); 618 DefExtOpr(1, BVMatTripletUnique, "TripletUnique", 3, 3, 619 "Matrix Real Real", 620 "(Matrix ijx, Real nrow, Real ncol)", 621 I2("Creates a Cholmod.R.Triplet VMatrix T of given dimensions from a list " 622 "of triplets ijx that can be expressed as a matrix with three columns. " 623 "Each triplet (i,j,x) defines an stored cell T[i,j]=x. Non listed ones are " 624 "assumed as zero. If row i or columns j index are not integers will be " 625 "truncated.\n" 626 "It's posible to remap row and column indexes of cells by specifying it " 627 "with rowIdx and colIdx arguments, that must be row or column matrices " 628 "of integer numbers.", 629 "Construye una VMatrix Cholmod.R.Triplet T con la sdimensiones dadas a " 630 "partir de una lista de tripletas ijx que pueden expresarse bien " 631 "como un conjunto de conjuntos de tres números cada uno, bien como " 632 "una matriz con tres columnas. Cada tripleta (i,j,x) define una celda " 633 "almacenada T(i,j)=x. Las celdas no listadas se asumen como cero.\n" 634 "Si los índices de fila i ó columna j no son enteros serán truncados.\n" 635 "Es posible reubicar los índices de las filas y columnas de las celdas " 636 "especificándolo con los argumentos rowIdx y colIdx, que deben ser " 637 "matrices fila o columna de números enteros."), 638 BOperClassify::MatrixAlgebra_); 639 //-------------------------------------------------------------------- 640 void BVMatTripletUnique::CalcContens() 641 //-------------------------------------------------------------------- 642 { 643 BMatrix<double>& ijx = (BMatrix<double>&)Mat(Arg(1)); 644 int nrow = (int)Real(Arg(2)); 645 int ncol = (int)Real(Arg(3)); 646 contens_.DMat2tripletUnique(ijx,nrow,ncol); 647 } 648 649 //-------------------------------------------------------------------- 614 650 DeclareContensClass(BMat, BMatTemporary, BMatVMat2Triplet); 615 651 DefExtOpr(1, BMatVMat2Triplet, "VMat2Triplet", 1, 2, … … 628 664 V.GetTriplet((BMatrix<double>&)contens_); 629 665 } 666 630 667 631 668 //--------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.
