Commit 9ce262d9 authored by BRAMAS Berenger's avatar BRAMAS Berenger
Browse files
parents 3569ff59 a62ea305
......@@ -26,18 +26,19 @@ int main(int argc, char** argv){
FHelpDescribeAndExit(argc, argv,"Test the bisection.",SvgOutParam,DimParam,FParameterDefinitions::OctreeHeight);
const char* filename = FParameters::getStr(argc, argv, FParameterDefinitions::InputFile.options, "../Addons/HMat/Data/unitCube1000_ONE_OVER_R.bin");
const char* filename = FParameters::getStr(argc, argv, FParameterDefinitions::InputFile.options, "../Addons/HMat/Data/unitCube1000.bin");
const int height = FParameters::getValue(argc, argv, FParameterDefinitions::OctreeHeight.options, 4);
const char* outputdir = FParameters::getStr(argc, argv, SvgOutParam.options, "/tmp/");
int readNbRows = 0;
int readNbCols = 0;
double* values = nullptr;
FAssertLF(FMatrixIO::read(filename, &values, &readNbRows, &readNbCols));
// Read distances
double* distances = nullptr;
FAssertLF(FMatrixIO::read(filename, &distances, &readNbRows, &readNbCols));
FAssertLF(readNbRows == readNbCols);
const int dim = readNbRows;
FCCLTreeCluster<double> tcluster(dim, values, CCL::CCL_TM_MAXIMUM /*CCL::CCL_TM_AVG_LINKAGE*/);
FCCLTreeCluster<double> tcluster(dim, distances, CCL::CCL_TM_MAXIMUM /*CCL::CCL_TM_AVG_LINKAGE*/);
std::unique_ptr<int[]> permutations(new int[dim]);
tcluster.fillPermutations(permutations.get());
......
......@@ -99,7 +99,7 @@ int main(int argc, char* argv[])
}
{
////////////////////////////////////////////////////////////////////
/// Build kernel matrix K
......@@ -140,7 +140,7 @@ int main(int argc, char* argv[])
/// Write kernel matrix in binary file
// Output file name
const std::string matrixName((distributionName + "_" + MatrixKernelID).c_str()); // if nothing specified then use file associated with n=50
const std::string matrixName((distributionName + "_" + MatrixKernelID).c_str());
const std::string fileName = ioPath + matrixName + ".bin";
// Write
......@@ -153,15 +153,64 @@ int main(int argc, char* argv[])
tWriteMat = timeWriteMat.tacAndElapsed();
std::cout << "... took @tWriteMat = "<< tWriteMat <<"\n";
}
{
////////////////////////////////////////////////////////////////////
/// Build distance matrix D
// Allocate memory
FReal* D = new FReal[matrixSize*matrixSize];
FBlas::setzero(int(matrixSize*matrixSize),D);
// Build (symmetric) kernel matrix
FTic timeAssK;
for(FSize idxRow = 0 ; idxRow < matrixSize ; ++idxRow)
for(FSize idxCol = idxRow ; idxCol < matrixSize ; ++idxCol) {
FReal diffX(grid[idxRow].getX()-grid[idxCol].getX());
FReal diffY(grid[idxRow].getY()-grid[idxCol].getY());
FReal diffZ(grid[idxRow].getZ()-grid[idxCol].getZ());
D[idxRow*matrixSize+idxCol] = FMath::Sqrt(diffX*diffX+diffY*diffY+diffZ*diffZ);
if(idxCol!=idxRow)
D[idxCol*matrixSize+idxRow] = D[idxRow*matrixSize+idxCol];
}
double tAssK = timeAssK.tacAndElapsed();
std::cout << "... took @tAssK = "<< tAssK <<"\n";
// Display matrix
const FSize displaySize = 10;
if(verbose==2) {
std::cout<<"\nD=["<<std::endl;
for ( FSize i=0; i<displaySize; ++i) {
for ( FSize j=0; j<displaySize; ++j)
std::cout << D[i*matrixSize+j] << " ";
std::cout<< std::endl;
}
std::cout<<"]"<<std::endl;
}
////////////////////////////////////////////////////////////////////
/// Write distance matrix in binary file
// Output file name
const std::string fileName = ioPath + distributionName + ".bin";
// Write
std::cout<< "Write matrix in binary file: " << fileName << "\n";
FTic timeWriteMat;
double tWriteMat;
timeWriteMat.tic();
FMatrixIO::write<FReal>(matrixSize,matrixSize,D,fileName);
tWriteMat = timeWriteMat.tacAndElapsed();
std::cout << "... took @tWriteMat = "<< tWriteMat <<"\n";
double tOverall = time.tacAndElapsed();
std::cout << "... took @tOverall = "<< tOverall <<"\n";
/// Free memory
delete[] K;
}
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment