Changeset 519d0f3 in tol
- Timestamp:
- Aug 26, 2010, 11:12:48 AM (16 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- daf1fa0
- Parents:
- cdcc881
- Location:
- tol/btol/vmatrix_type
- Files:
-
- 4 edited
-
tol_bvmat.h (modified) (3 diffs)
-
vmat_convert.cpp (modified) (2 diffs)
-
vmat_stats.cpp (modified) (1 diff)
-
vmatgra.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tol/btol/vmatrix_type/tol_bvmat.h
rcdcc881 r519d0f3 436 436 void DMat2triplet(const BMatrix<double>& d, int nrow, int columns, 437 437 const BArray<int>& rowIdx, const BArray<int>& colIdx); 438 bool AddTriplet(const BMatrix<double>& ijx); 438 439 void BSet2sparse (const BSet& sparseDef); 439 440 void BPol2sparse (const BPolyn<BDat>& pol_, int nrow, int ncol); … … 532 533 void TruncStdGaussian(const BVMat& D, const BVMat& d_, 533 534 const BVMat& z0_, int ncol, int burnin); 535 void Histogram(const BVMat& M, int parts); 536 void Histogram(const BVMat& M, int parts, double min, double max); 534 537 private: 535 538 static cholmod_dense_struct* bRd_rand(int nrow, int ncol, … … 541 544 BVMat& b, 542 545 BVMat& z); 546 void Histogram_bRd(const BVMat& M, int parts); 547 void Histogram_bRd(const BVMat& M, int parts, double min, double max); 543 548 544 549 /*------------------------------------------------------------------------------ -
tol/btol/vmatrix_type/vmat_convert.cpp
rcdcc881 r519d0f3 307 307 { 308 308 warn_convert2bRd(fName,A); 309 A_ = new BVMat(A, ESC_blasRdense); 309 A_ = new BVMat; 310 A_->Convert(A, ESC_blasRdense); 310 311 } 311 312 return(0); … … 616 617 }; 617 618 618 619 //////////////////////////////////////////////////////////////////////////////// 620 bool BVMat::AddTriplet(const BMatrix<double>& ijx) 621 //////////////////////////////////////////////////////////////////////////////// 622 { 623 static BText fName = "AddTriplet(Matrix triplets)"; 624 Error(BText("Still not impemented function VMatrix ")+fName); 625 return(false); 626 /* 627 int k, n = ijx.Rows(); 628 bool ok = true; 629 if(code_ != ESC_chlmRtriplet) 630 { 631 err_wrong_defined(fName, *this); 632 ok = false; 633 } 634 else 635 { 636 int nrow; 637 int ncol; 638 cholmod_triplet *all = cholmod_allocate_triplet 639 (nrow,ncol,n,0,CHOLMOD_REAL,common_); 640 int* r_ = (int*) s_.chlmRtriplet_->i; 641 int* c_ = (int*) s_.chlmRtriplet_->j; 642 double* x_ = (double*)s_.chlmRtriplet_->x; 643 for(k=0; k<n; k++) 644 { 645 r_[k] = (int)ijx(k,0)-1; 646 c_[k] = (int)ijx(k,1)-1; 647 x_[k] = ijx(k,2); 648 if((r_[k]<0)||(r_[k]>=nrow)) 649 { 650 err_cannot_apply(fName, 651 BText("Row index ")+(r_[k]+1)+" out of range 1..."+(nrow+1), 652 *this); 653 ok = false; 654 break; 655 } 656 else if((c_[k]<0)||(c_[k]>=ncol)) 657 { 658 err_cannot_apply(fName, 659 BText("Columns index ")+(c_[k]+1)+" out of range 1..."+(ncol+1), 660 *this); 661 ok = false; 662 break; 663 } 664 s_.chlmRtriplet_->nnz++; 665 } 666 } 667 return(false); 668 */ 669 }; 619 670 620 671 //////////////////////////////////////////////////////////////////////////////// -
tol/btol/vmatrix_type/vmat_stats.cpp
rcdcc881 r519d0f3 779 779 }; 780 780 781 781 //////////////////////////////////////////////////////////////////////////////// 782 void BVMat::Histogram_bRd(const BVMat& M, int parts, double min, double max) 783 //////////////////////////////////////////////////////////////////////////////// 784 { 785 int i,j,p; 786 int n = M.s_.blasRdense_->nzmax; 787 int r = M.s_.blasRdense_->nrow; 788 int c = M.s_.blasRdense_->ncol; 789 BlasRDense(parts, c+1); 790 BArray<double> sorted(r); 791 double* h = (double*)s_.blasRdense_->x; 792 double step = (max-min)/double(parts); 793 for(p=0; p<parts-1; p++) 794 { 795 *(h++) = min+step*(p+1); 796 } 797 *(h++) = max; 798 memset(h,0,sizeof(double)*parts*c); 799 const double* x = (const double*)M.s_.blasRdense_->x; 800 for(j=0; j<c; j++) 801 { 802 double* h0 = ((double*)s_.blasRdense_->x)+r*j; 803 for(i=0; i<r; i++, x++) 804 { 805 p = (int)((*x-min)/step)-1; 806 if(p<0) { p=0; } 807 if(p>=parts) { p=parts-1; } 808 h0[p] += 1.0/parts; 809 } 810 } 811 }; 812 813 //////////////////////////////////////////////////////////////////////////////// 814 void BVMat::Histogram_bRd(const BVMat& M, int parts) 815 //////////////////////////////////////////////////////////////////////////////// 816 { 817 int k; 818 int n = M.s_.blasRdense_->nzmax; 819 double* x = (double*)M.s_.blasRdense_->x; 820 double min = BDat::PosInf(); 821 double max = BDat::NegInf(); 822 for(k=0; k<n; k++, x++) 823 { 824 if(*x<min) { min=*x; } 825 if(*x>max) { max=*x; } 826 } 827 Histogram_bRd(M,parts,min,max); 828 }; 829 830 //////////////////////////////////////////////////////////////////////////////// 831 void BVMat::Histogram(const BVMat& M_, int parts, double min, double max) 832 //////////////////////////////////////////////////////////////////////////////// 833 { 834 BVMat *M__=NULL; 835 convertIfNeeded_all2bRd(M_, M__, "Histogram"); 836 BVMat &M = *M__; 837 Histogram_bRd(M,parts,min,max); 838 if(M__!=&M_) { delete M__; } 839 } 840 841 //////////////////////////////////////////////////////////////////////////////// 842 void BVMat::Histogram(const BVMat& M_, int parts) 843 //////////////////////////////////////////////////////////////////////////////// 844 { 845 BVMat *M__=NULL; 846 convertIfNeeded_all2bRd(M_, M__, "Histogram"); 847 BVMat &M = *M__; 848 Histogram_bRd(M,parts); 849 if(M__!=&M_) { delete M__; } 850 } -
tol/btol/vmatrix_type/vmatgra.cpp
rcdcc881 r519d0f3 2536 2536 } 2537 2537 2538 2538 //-------------------------------------------------------------------- 2539 DeclareContensClass(BVMat, BVMatTemporary, BVMatHistogram); 2540 DefExtOpr(1, BVMatHistogram, "Histogram", 2, 4, "VMatrix Real Real Real", 2541 "(VMatrix M, Real p [, Real min, Real max])", 2542 I2("Makes a frequency analysis of p intervals for the each column " 2543 "of a matrix M:rxc and returns a matrix with c+1 columns and p rows. " 2544 "In the first column contains the upper bound of each interval. " 2545 "The rest of columns j=2..c+1 contain the ratio of values of (j-1)-th " 2546 "column of M belonging to the interval corresponding to the row.", 2547 "Hace un analisis de frecuencia de p intervalos para cada " 2548 "columna de una matriz M:rxc y devuelve una matriz con c+1 columnas y p filas. " 2549 "La primera columna contiene el limite superior de cada intervalo. " 2550 "Las siguientes columnas j=2..c+1 contienen la proporción de valores de " 2551 "la columna (j-1)-ésima de M que pertenecen al intervalo correspondiente " 2552 "a la fila.")+"\n"+ 2553 I2("Defining the size of internal intervals as ", 2554 "Definiendo el tamaño de los intervalos interiores como ")+"\n"+ 2555 " h = (max-min)/p\n"+ 2556 I2("we will have the next p intervals", 2557 "tendremos los siguientes p intervalos")+"\n"+ 2558 " min < x <= min + h \n"+ 2559 " min+h < x <= min + h*2 \n"+ 2560 " ... \n"+ 2561 " min+h*(p-1) < x <= min + h*p = max \n", 2562 BOperClassify::Statistic_); 2563 //-------------------------------------------------------------------- 2564 void BVMatHistogram::CalcContens() 2565 //-------------------------------------------------------------------- 2566 { 2567 BVMat& M = VMat (Arg(1)); 2568 int parts = (BInt)Real(Arg(2)); 2569 if(Arg(3) && Arg(4)) 2570 { 2571 double min = Real(Arg(3)); 2572 double max = Real(Arg(4)); 2573 contens_.Histogram(M,parts,min,max); 2574 } 2575 else 2576 { 2577 contens_.Histogram(M,parts); 2578 } 2579 //contens_.Pack(0.5) 2580 } 2581 2582 /* 2583 //-------------------------------------------------------------------- 2584 class BSetMergeTriplet: public BExternalOperator 2585 //-------------------------------------------------------------------- 2586 { 2587 public: 2588 BSetMergeTriplet() 2589 : BExternalOperator 2590 ( 2591 "MergeTriplet", GraVMatrix(), "VMatrix Matrix", NIL, 2, 2, 2592 "(VMatrix cum, Matrix triplets)", 2593 I2("" , 2594 ""), 2595 BOperClassify::MatrixtAlgebra_ 2596 ) 2597 { 2598 } 2599 2600 ~BSetMergeTriplet() {} 2601 2602 BSyntaxObject* Evaluator(BList* arg) const 2603 { 2604 if(CheckNonDeclarativeAction("MergeTriplet")) { return(NULL); } 2605 BUserSet* uCum = UVMat(lst->Car()); 2606 BVMat& cum = uCum->Contens(); 2607 BMat& triplets = Mat(Arg(lst->Cdr()->Car())); 2608 cum.AddTriplet(triplets); 2609 SAFE_DESTROY(arg, uCum); 2610 return(uCum); 2611 } 2612 private: 2613 DeclareClassNewDelete(BSetMergeTriplet); 2614 }; 2615 */ 2616 2617
Note: See TracChangeset
for help on using the changeset viewer.
