/**
 * Test sull'uso dei costruttori della classe cbuffer. In totale creo 5 cbuffer.
*/
void testCostructor(){
	cbuffer<double> cb(10, 1.2); 
	cbuffer<int> cb2(11,3);
	std::cout << "size: "<<cb.get_size()<<" items: "<<cb.get_items()<<" //" << cb << std::endl;
	std::cout << "size: "<<cb2.get_size()<<" items: "<<cb2.get_items()<<" //" << cb2 << std::endl;
	cb=cb2;
	cbuffer<double> cb3(cb2);
	std::cout << "size: "<<cb.get_size()<<" items: "<<cb.get_items()<<" //" << cb << std::endl;
	std::cout << "size: "<<cb3.get_size()<<" items: "<<cb3.get_items()<<" //" << cb3 << std::endl;
	
	cbuffer<char> cb1(5,'a');
	cbuffer<char> cb4(cb1);
	std::cout << "size: "<<cb4.get_size()<<" items: "<<cb4.get_items()<<" //" << cb4 << std::endl;
}
示例#2
0
void TestSymDiv_E2(tmv::DivType dt, PosDefCode pdc)
{
    const int N = 10;

    std::vector<tmv::SymMatrixView<T> > s;
    std::vector<tmv::SymMatrixView<std::complex<T> > > cs;
    MakeSymList(s,cs,pdc);

    tmv::Matrix<T> a1(N,N);
    for (int i=0; i<N; ++i) for (int j=0; j<N; ++j) a1(i,j) = T(1-3*i+j);
    a1.diag().addToAll(T(10)*N);
    a1 /= T(10);
    tmv::Matrix<std::complex<T> > ca1 = a1 * std::complex<T>(3,-4);

    tmv::BandMatrix<T> b1(a1,1,3);
    tmv::BandMatrix<std::complex<T> > cb1(ca1,1,3);

    tmv::BandMatrix<T> b1v = b1.view();
    tmv::BandMatrix<std::complex<T> > cb1v = cb1.view();

#if (XTEST & 2)
    tmv::BandMatrix<T> b3(a1.colRange(0,N-2),1,3);
    tmv::BandMatrix<std::complex<T> > cb3(ca1.colRange(0,N-2),1,3);
    tmv::BandMatrix<T> b4(a1.rowRange(0,N-2),1,3);
    tmv::BandMatrix<std::complex<T> > cb4(ca1.rowRange(0,N-2),1,3);

    tmv::BandMatrix<T> b3v = b3.view();
    tmv::BandMatrix<std::complex<T> > cb3v = cb3.view();
    tmv::BandMatrix<T> b4v = b4.view();
    tmv::BandMatrix<std::complex<T> > cb4v = cb4.view();
#endif

    for(size_t i=START;i<s.size();i++) {
        if (showstartdone)
            std::cout<<"Start loop: i = "<<i<<", si = "<<tmv::TMV_Text(s[i])<<
                "  "<<s[i]<<std::endl;
        tmv::SymMatrixView<T> si = s[i];
        tmv::SymMatrixView<std::complex<T> > csi = cs[i];

        TestMatrixDivArith1(dt,b1v,si,cb1v,csi,"Sym/SquareBandMatrix");
        if (dt == tmv::LU) continue;
#if (XTEST & 2)
        TestMatrixDivArith1(dt,b3v,si,cb3v,csi,"Sym/NonSquareBandMatrix");
        TestMatrixDivArith1(dt,b4v,si,cb4v,csi,"Sym/NonSquareBandMatrix");
#endif
    }
}
/**
 * Test per verificare la corretta esecuzione di vari metodi fondamentali. (utilizzo
 * di stampa come procedura d'appoggio).
*/
void testValueGetSetOperator(){
	cbuffer<int> cb1(5);
	cbuffer<float> cb2(4,2.2);
	cbuffer<std::string> cb3(3,"stringa");
	std::cout << "test get_size() e get_items(): " << std::endl;
	std::cout << "cb1 size: " << cb1.get_size() << std::endl;
	std::cout << "cb2 size: " << cb2.get_size() << std::endl;
	std::cout << "cb3 size: " << cb3.get_size() << std::endl;
	std::cout << "cb1 items: " << cb1.get_items() << std::endl;
	std::cout << "cb2 items: " << cb2.get_items() << std::endl;
	std::cout << "cb3 items: " << cb3.get_items() << std::endl;
	
	std::cout << "test get_cbuffer(size_type) e set_cbuffer(size_type, const &T):" << std::endl;
	cb2.set_cbuffer(3, 4);
	std::cout << "cb2[3] set 4 " << std::endl;
	std::cout << "cb2[3] get: " << cb2.get_cbuffer(3) << std::endl;
	
	std::cout << "test T& value(size_type index):" << std::endl;
	cb3.value(0)="fiorellino";
	std::cout << "scrittura cb3.value(0)"<< std::endl;
	std::cout << "lettura cb3.value(0)= " << cb3.value(0) << std::endl;
	
	std::cout << "test operator[]" << std::endl;
	cb3[2]="alberello";
	std::cout << "scrittura cb3[2] " << std::endl;
	std::cout << "lettra cb3[2] " << cb3[2] << std::endl;
	
	std::cout << "stampa(const cbuffer<int>)" << std::endl;
	cbuffer<int> cb4(6);
	cb4.insert(1);
	cb4.insert(2);
	cb4.insert(3);
	cb4.insert(4);
	std::cout << cb4 << std::endl;
	stampa(cb4);
}
示例#4
0
文件: sio2man.c 项目: sp193/ps2sdk
/* 58 */
void sio2_func4()
{
	if (cb4)
		cb4();
}