[ create a new paste ] login | about

Link: http://codepad.org/ztkFOQv3    [ raw code | fork ]

nima - C++, pasted on Jan 27:
#include <cstdio>
#include <iostream>

int dim=8;
int NBT=2;
int BS=4;

extern "C" {

	void dlarfb_(char* SIDE,char* TRANS,char* DIRECT,char* STOREV,int* M,int* N,int* K,double* V,int* LDV,double* T,int* LDT,double* C,int* LDC,double* WORK,int* LDWORK);
}

void disp(double * M, char a, int m, int n){

	std::cout<<a<<std::endl;
	for(int i=0;i<m;++i){
		for(int j=0;j<n;++j){
			std::cout<<M[(m*i)+j]<<'\t';
		}
		std::cout<<std::endl;
	}
	std::cout<<std::endl;

}

double* part_of_matrix(double * a, int n, int r, int c){

	static	double v[16];

	int start= n*dim+((c-1)*n);
	int pos=0;

	for(int i=start; i<start+(n*dim); i=dim+i){
		for(int j=0; j<n; ++j){
			//std::cout<<i<<' '<<j<<std::endl;
			v[pos]=a[i+j];
			pos++;
			//std::cout<<a[i+j];

		}
		//	std::cout<<std::endl;
	}
	//	std::cout<<std::endl;
	pos=0;
	return v;


}

void dlarfb(double* A, int i, int j){

	double* C=part_of_matrix(A, BS, i, j);

	char SIDE='L';
	char TRANS='N';
	char DIRECT='F';
	char STOREV='R';
	int M=4;
	int N=4;
	int K=4;//shobhe nak!
	double V[4*4];
	for(int a=0;a<4*4; a++)
		V[a]=0;

	int LDV=4;//kami shobhe
	double T[4*4];
	for(int a=0;a<4*4; a++)
		T[a]=0;

	int LDT=4;
	//	double C; 
	int LDC=4;
	double WORK[4*4];
	for(int a=0;a<4*4; a++)
		WORK[a]=0;

	int LDWORK=4;



	disp(C,'C', M, N);


	dlarfb_(&SIDE, &TRANS, &DIRECT, &STOREV, &M, &N, &K, V, &LDV, T, &LDT, C, &LDC, WORK, &LDWORK);
	
	disp(C,'C',M ,N );
	disp(V,'V',M ,N );
	disp(T,'T',M ,N );
	disp(WORK,'W',M ,N );

	


}



int main(){

	//	double A [4*4] = {
	//		1,2,3,4,
	//		5,6,7,8,
	//		9,10,11,12,
	//		13,14,15,16
	//	};

	double K [8*8] = {
		1,2,3,4,5,6,7,8,
		9,10,11,12,13,14,15,16,
		17,18,19,20,21,22,23,24,
		25,26,27,28,29,30,31,32,
		33,34,35,36,37,38,39,40,
		41,42,43,44,45,46,47,48,
		49,50,51,52,53,54,55,56,
		57,58,59,60,61,62,63,64
	};


	for (int i=1; i<=NBT-1 ;++i){


		for (int j=i+1; j<=NBT; ++j){
			dlarfb(K,i+1,j);
		}

	}

	return 0;
}

result :

C
37	38	39	40	
45	46	47	48	
53	54	55	56	
61	62	63	64	

C
37	38	39	40	
45	46	47	48	
53	54	55	56	
61	62	63	64	

V
0	0	0	0	
0	0	0	0	
0	0	0	0	
0	0	0	0	

T
0	0	0	0	
0	0	0	0	
0	0	0	0	
0	0	0	0	

W
0	0	0	0	
0	0	0	0	
0	0	0	0	
0	0	0	0


Create a new paste based on this one


Comments: