|
Ublas : |
From: Seabook (cipoke_at_[hidden])
Date: 2006-12-07 10:48:04
Thanks. Can you post or mail the source code, please?
======================================
#include "stdafx.h"
#include "time.h"
#include "gc_matrix.h"
#using <mscorlib.dll>
#include <boost\numeric\ublas\matrix.hpp>
#include <boost\numeric\ublas\symmetric.hpp>
#include <boost\numeric\ublas\matrix_sparse.hpp>
#include <boost\numeric\ublas\operation.hpp>
#include <boost\numeric\ublas\fwd.hpp>
#include <boost\numeric\ublas\expression_types.hpp>
#include <boost\numeric\ublas\matrix_proxy.hpp>
#include <boost\numeric\ublas\triangular.hpp>
#include <boost/numeric/ublas/io.hpp>
using namespace System;
//#define NDEBUG
int _tmain()
{
using namespace boost::numeric::ublas;
int
i,j,ta1,ta2,dt_normal,tb1,tb2,dt_Sparse,tc1,tc2,dt_Symmetry,dt_smc,dt_smr;
int dt_1,dt_2,dt_3,dt_4,dt_5,dt_6,dt_7,dt_8,dt_9,dt_10,dt_11;
float m1 __gc[,]=new float __gc[100,100];
float m2 __gc[,]=new float __gc[100,100];
float m3 __gc[,]=new float __gc[100,100];
symmetric_matrix<float,upper> sy1(100,100);
symmetric_matrix<float,lower> sy2(100, 100),sy3(100,100);
compressed_matrix<float,column_major>
sp1(100,100),sp2(100,100),sp3(100,100);
matrix <float, column_major> m4(100,100);
matrix <float, row_major> m5(100,100),m6(100,100);
//---initial matrix-------//
/*
for(i=0;i<99;i++)
{
for(j=0;j<99;j++)
{
sp1(i,j)=0;
sp2(i,j)=0;
sy1(i,j)=0;
sy1(i,j)=0;
m4(i,j)=0;
m5(i,j)=0;
}
sp1(i,j)=1;
sp2(i,j)=1;
sy1(i,j)=1;
sy2(i,j)=1;
m4(i,j)=1;
m5(i,j)=1;
}
*/
//--sparse * sparse column mode //...(1)
tb1=clock();
for(i=0;i<20;i++)
{
sp3=prod(sp1,sp2);
}
tb2=clock();
dt_1=tb2-tb1;
printf("%d", dt_1);
//--sparse * normal column mode //...(2)
ta1=clock();
for(i=0;i<20;i++)
{
sp3=prod(sp1,m4);
}
ta2=clock();
dt_2=ta2-ta1;
printf("%d", dt_2);
//--sparse * normal row mode //...(3)
ta1=clock();
for(i=0;i<20;i++)
{
sp3=prod(sp1,m5);
}
ta2=clock();
dt_3=ta2-ta1;
printf("%d", dt_3);
//--sparse * symmerty upper mode //...(4)
ta1=clock();
for(i=0;i<20;i++)
{
sp3=prod(sp1,sy1);
}
ta2=clock();
dt_4=ta2-ta1;
printf("%d", dt_4);
//--sparse * symmerty lower mode //...(5)
ta1=clock();
for(i=0;i<20;i++)
{
sp3=prod(sp1,sy2);
}
ta2=clock();
dt_5=ta2-ta1;
printf("%d", dt_5);
//--Normal * Normal mode // ....(11)
ta1=clock();
for(i=0;i<20;i++)
{
Matrix_Multi2(100,100,100,&m1[0,0],&m2[0,0],&m3[0,0]);
}
ta2=clock();
dt_11=ta2-ta1;
printf("%d", dt_11);
// axpy_prod(sp1,sp2,sp3,true);
Console::WriteLine(S" Good Job!!! ");
return 0;
}
-- View this message in context: http://www.nabble.com/Bad-prod-efficiency-of-sparse-symmetry-matrix---tf2766020.html#a7741552 Sent from the Boost - uBLAS mailing list archive at Nabble.com.