initial commit
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
//=====================================================
|
||||
// File : size_lin_log.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, mar déc 3 18:59:37 CET 2002
|
||||
//=====================================================
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
#ifndef SIZE_LIN_LOG
|
||||
#define SIZE_LIN_LOG
|
||||
|
||||
#include "size_log.hh"
|
||||
|
||||
template <class Vector>
|
||||
void size_lin_log(const int nb_point, const int /*size_min*/, const int size_max, Vector& X) {
|
||||
int ten = 10;
|
||||
int nine = 9;
|
||||
|
||||
X.resize(nb_point);
|
||||
|
||||
if (nb_point > ten) {
|
||||
for (int i = 0; i < nine; i++) {
|
||||
X[i] = i + 1;
|
||||
}
|
||||
|
||||
Vector log_size;
|
||||
size_log(nb_point - nine, ten, size_max, log_size);
|
||||
|
||||
for (int i = 0; i < nb_point - nine; i++) {
|
||||
X[i + nine] = log_size[i];
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < nb_point; i++) {
|
||||
X[i] = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// for (int i=0;i<nb_point;i++){
|
||||
|
||||
// INFOS("computed sizes : X["<<i<<"]="<<X[i]);
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,50 @@
|
||||
//=====================================================
|
||||
// File : size_log.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, lun sep 30 14:23:17 CEST 2002
|
||||
//=====================================================
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
#ifndef SIZE_LOG
|
||||
#define SIZE_LOG
|
||||
|
||||
#include "math.h"
|
||||
// The Vector class must satisfy the following part of STL vector concept :
|
||||
// resize() method
|
||||
// [] operator for setting element
|
||||
// the vector element are int compatible.
|
||||
template <class Vector>
|
||||
void size_log(const int nb_point, const int size_min, const int size_max, Vector& X) {
|
||||
X.resize(nb_point);
|
||||
|
||||
float ls_min = log(float(size_min));
|
||||
float ls_max = log(float(size_max));
|
||||
|
||||
float ls = 0.0;
|
||||
|
||||
float delta_ls = (ls_max - ls_min) / (float(nb_point - 1));
|
||||
|
||||
int size = 0;
|
||||
|
||||
for (int i = 0; i < nb_point; i++) {
|
||||
ls = ls_min + float(i) * delta_ls;
|
||||
|
||||
size = int(exp(ls));
|
||||
|
||||
X[i] = size;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,128 @@
|
||||
//=============================================================================
|
||||
// File : utilities.h
|
||||
// Created : mar jun 19 13:18:14 CEST 2001
|
||||
// Author : Antoine YESSAYAN, Paul RASCLE, EDF
|
||||
// Project : SALOME
|
||||
// Copyright : EDF 2001
|
||||
// $Header$
|
||||
//=============================================================================
|
||||
|
||||
/* --- Definition macros file to print information if _DEBUG_ is defined --- */
|
||||
|
||||
#ifndef UTILITIES_H
|
||||
#define UTILITIES_H
|
||||
|
||||
#include <stdlib.h>
|
||||
// # include <iostream> ok for gcc3.01
|
||||
#include <iostream>
|
||||
|
||||
/* --- INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */
|
||||
|
||||
#define HEREWEARE \
|
||||
cout << flush; \
|
||||
cerr << __FILE__ << " [" << __LINE__ << "] : " << flush;
|
||||
#define INFOS(chain) \
|
||||
{ \
|
||||
HEREWEARE; \
|
||||
cerr << chain << endl; \
|
||||
}
|
||||
#define PYSCRIPT(chain) \
|
||||
{ \
|
||||
cout << flush; \
|
||||
cerr << "---PYSCRIPT--- " << chain << endl; \
|
||||
}
|
||||
|
||||
/* --- To print date and time of compilation of current source on stdout --- */
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define COMPILER "g++";
|
||||
#elif defined(__sun)
|
||||
#define COMPILER "CC";
|
||||
#elif defined(__KCC)
|
||||
#define COMPILER "KCC";
|
||||
#elif defined(__PGI)
|
||||
#define COMPILER "pgCC";
|
||||
#else
|
||||
#define COMPILER "undefined";
|
||||
#endif
|
||||
|
||||
#ifdef INFOS_COMPILATION
|
||||
#error INFOS_COMPILATION already defined
|
||||
#endif
|
||||
#define INFOS_COMPILATION \
|
||||
{ \
|
||||
cerr << flush; \
|
||||
cout << __FILE__; \
|
||||
cout << " [" << __LINE__ << "] : "; \
|
||||
cout << "COMPILED with " << COMPILER; \
|
||||
cout << ", " << __DATE__; \
|
||||
cout << " at " << __TIME__ << endl; \
|
||||
cout << "\n\n"; \
|
||||
cout << flush; \
|
||||
}
|
||||
|
||||
#ifdef _DEBUG_
|
||||
|
||||
/* --- the following MACROS are useful at debug time --- */
|
||||
|
||||
#define HERE \
|
||||
cout << flush; \
|
||||
cerr << "- Trace " << __FILE__ << " [" << __LINE__ << "] : " << flush;
|
||||
#define SCRUTE(var) \
|
||||
HERE; \
|
||||
cerr << #var << "=" << var << endl;
|
||||
#define MESSAGE(chain) \
|
||||
{ \
|
||||
HERE; \
|
||||
cerr << chain << endl; \
|
||||
}
|
||||
#define INTERRUPTION(code) \
|
||||
HERE; \
|
||||
cerr << "INTERRUPTION return code= " << code << endl; \
|
||||
exit(code);
|
||||
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(condition) \
|
||||
if (!(condition)) { \
|
||||
HERE; \
|
||||
cerr << "CONDITION " << #condition << " NOT VERIFIED" << endl; \
|
||||
INTERRUPTION(1); \
|
||||
}
|
||||
#endif /* ASSERT */
|
||||
|
||||
#define REPERE \
|
||||
cout << flush; \
|
||||
cerr << " --------------" << endl << flush;
|
||||
#define BEGIN_OF(chain) \
|
||||
{ \
|
||||
REPERE; \
|
||||
HERE; \
|
||||
cerr << "Begin of: " << chain << endl; \
|
||||
REPERE; \
|
||||
}
|
||||
#define END_OF(chain) \
|
||||
{ \
|
||||
REPERE; \
|
||||
HERE; \
|
||||
cerr << "Normal end of: " << chain << endl; \
|
||||
REPERE; \
|
||||
}
|
||||
|
||||
#else /* ifdef _DEBUG_*/
|
||||
|
||||
#define HERE
|
||||
#define SCRUTE(var)
|
||||
#define MESSAGE(chain)
|
||||
#define INTERRUPTION(code)
|
||||
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(condition)
|
||||
#endif /* ASSERT */
|
||||
|
||||
#define REPERE
|
||||
#define BEGIN_OF(chain)
|
||||
#define END_OF(chain)
|
||||
|
||||
#endif /* ifdef _DEBUG_*/
|
||||
|
||||
#endif /* ifndef UTILITIES_H */
|
||||
@@ -0,0 +1,71 @@
|
||||
//=====================================================
|
||||
// File : dump_file_x_y.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, lun sep 30 14:23:20 CEST 2002
|
||||
//=====================================================
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
#ifndef XY_FILE_HH
|
||||
#define XY_FILE_HH
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
bool read_xy_file(const std::string& filename, std::vector<int>& tab_sizes, std::vector<double>& tab_mflops,
|
||||
bool quiet = false) {
|
||||
std::ifstream input_file(filename.c_str(), std::ios::in);
|
||||
|
||||
if (!input_file) {
|
||||
if (!quiet) {
|
||||
INFOS("!!! Error opening " << filename);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int nb_point = 0;
|
||||
int size = 0;
|
||||
double mflops = 0;
|
||||
|
||||
while (input_file >> size >> mflops) {
|
||||
nb_point++;
|
||||
tab_sizes.push_back(size);
|
||||
tab_mflops.push_back(mflops);
|
||||
}
|
||||
SCRUTE(nb_point);
|
||||
|
||||
input_file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
// The Vector class must satisfy the following part of STL vector concept :
|
||||
// resize() method
|
||||
// [] operator for setting element
|
||||
// the vector element must have the << operator define
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <class Vector_A, class Vector_B>
|
||||
void dump_xy_file(const Vector_A& X, const Vector_B& Y, const std::string& filename) {
|
||||
ofstream outfile(filename.c_str(), ios::out);
|
||||
int size = X.size();
|
||||
|
||||
for (int i = 0; i < size; i++) outfile << X[i] << " " << Y[i] << endl;
|
||||
|
||||
outfile.close();
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user