5#include "GaudiKernel/StatusCode.h"
17 charAddress(
auto & v){
18 return reinterpret_cast<char *
>(&
v);
67 throw std::range_error(
"AlVec Assignment: size does not match!" );
71 double* q =
v.m_ptr_data +
m_size;
88 if (
this==&
v)
return *
this;
91 throw std::range_error(
"AlVec Assignment: size does not match!" );
102 throw std::range_error(
"operator+: vectors size does not match!" );
108 double* q =
v.m_ptr_data +
m_size;
109 double*
r = b.m_ptr_data +
m_size;
118 throw std::range_error(
"operator+=: vectors size does not match!" );
122 double* q =
v.m_ptr_data +
m_size;
131 throw std::range_error(
"operator-: vectors size does not match!" );
137 double* q =
v.m_ptr_data +
m_size;
138 double*
r = b.m_ptr_data +
m_size;
147 throw std::range_error(
"operator+=: vectors size does not match!" );
151 double* q =
v.m_ptr_data +
m_size;
161 throw std::range_error(
"scalar product: vectors size does not match!" );
165 double* q =
v.m_ptr_data +
m_size;
174 throw std::range_error(
"Left hand vector-matrix multiplication: size does not match!" );
179 for (
int i=0;i<m.ncol();i++) {
180 for (
int j=0;j<
m_size;j++) *(b.m_ptr_data+i) += *(
m_ptr_data+j)*m.elemc(j, i);
188 throw std::range_error(
"Left hand vector-matrix multiplication: size does not match!" );
193 for (
int i=0;i<
m_size;i++) {
194 for (
int j=0;j<
m_size;j++) *(b.m_ptr_data+i) += *(
m_ptr_data+j)*m.elemc(j, i);
225 if ( Nnew>=0 && Nnew !=
m_size ) {
244 const int start = shift*
index;
246 if(start<m_size && index>=0){
247 for(
int row=start; row<
m_size; row++) {
266 if (counter==5-control) { counter=0; shift++; }
278 throw std::range_error(
"Vector of indices larger than matrix size." );
283 for (
int i=0;i<n-1;i++)
284 for (
int j=i+1; j<n; j++)
292 for (
int i=0;i<n;i++) {
295 throw std::out_of_range(
"AlVec::RemoveElements: Index goes beyond matrix " );
320StatusCode
AlVec::Write(std::string_view filename,
bool binary,
double scale,
321 const std::map<int,unsigned long long> & moduleIndexMap,
float version)
323 std::ofstream outvec;
329 fullName.append(filename);
330 outvec.open(fullName, std::ios::binary);
332 return StatusCode::FAILURE;
333 outvec.write(charAddress(io_size),
sizeof (io_size));
334 outvec.write(charAddress(scale),
sizeof (scale));
335 outvec.write(charAddress(version),
sizeof (version));
339 fullName.append(filename);
340 outvec.open(fullName);
342 return StatusCode::FAILURE;
343 outvec.setf(std::ios::fixed);
344 outvec.setf(std::ios::showpoint);
346 outvec <<
"DoF: " << std::setw(6) <<
m_size << std::endl;
347 outvec <<
"scale: " << std::setw(18) << scale << std::endl;
348 outvec <<
"AlVec version: " << std::setw(6) << version << std::endl;
354 for(
int i=0; i<
m_size; i++) {
355 auto itcod=moduleIndexMap.find(i/6);
356 if (itcod != moduleIndexMap.end()) {
357 ielem = (itcod->second);
363 outvec.write(charAddress((ielem)),
sizeof (ielem));
364 outvec.write(charAddress((velem)),
sizeof (velem));
367 outvec << std::setw(20) << ielem << std::setw(18) << velem << std::endl;
370 return StatusCode::SUCCESS;
375 const std::map<int,unsigned long long> & moduleIndexMap,
float version)
377 std::ofstream outvec;
380 if (
sc!=StatusCode::SUCCESS)
return StatusCode::FAILURE;
385 for(
int i=0; i<
m_size; i++) {
386 auto itcod=moduleIndexMap.find(i);
387 if (itcod != moduleIndexMap.end())
388 ielem = (itcod->second);
393 outvec.write(charAddress((ielem)),
sizeof (ielem));
394 outvec.write(charAddress((velem)),
sizeof (velem));
397 outvec << std::setw(20) << ielem << std::setw(18) << velem << std::endl;
400 return StatusCode::SUCCESS;
405 const std::map<int,std::string> & moduleNameMap,
float version)
407 std::ofstream outvec;
410 if (
sc!=StatusCode::SUCCESS)
return StatusCode::FAILURE;
415 for(
int i=0; i<
m_size; i++) {
416 auto itcod=moduleNameMap.find(i);
417 if (itcod != moduleNameMap.end()) {
418 elem = (itcod->second);
424 std::cout<<
"can't write module name in binary output!"<<std::endl;
425 return StatusCode::FAILURE;
428 outvec << std::setw(20) << elem << std::setw(18) << velem << std::endl;
431 return StatusCode::SUCCESS;
436 float version, std::ofstream& outvec)
441 outvec.open(
m_pathbin.append(filename), std::ios::binary);
443 return StatusCode::FAILURE;
444 outvec.write(charAddress(io_size),
sizeof (io_size));
445 outvec.write(charAddress(scale),
sizeof (scale));
446 outvec.write(charAddress(version),
sizeof (version));
452 return StatusCode::FAILURE;
453 outvec.setf(std::ios::fixed);
454 outvec.setf(std::ios::showpoint);
456 outvec <<
"DoF: " << std::setw(6) <<
m_size << std::endl;
457 outvec <<
"scale: " << std::setw(18) << scale << std::endl;
458 outvec <<
"AlVec version: " << std::setw(6) << version << std::endl;
460 return StatusCode::SUCCESS;
465 std::map<int,unsigned long long> &modmap,
float &version)
467 bool StdUnits =
true;
470 return StatusCode::FAILURE;
473 std::ifstream invec((
m_pathbin+filename), std::ios::binary);
476 return StatusCode::FAILURE;
480 invec.read(charAddress(vsiz),
sizeof (vsiz));
484 invec.read(charAddress(scale),
sizeof(scale));
488 invec.read(charAddress(version),
sizeof (version));
496 for(
int i=0; i<
m_size; i++) {
497 invec.read(charAddress(ielem),
sizeof (ielem));
500 invec.read(charAddress(velem),
sizeof (velem));
508 return StatusCode::SUCCESS;
513 std::ifstream invec((filename), std::ios::binary);
515 return StatusCode::FAILURE;
518 invec.read(charAddress(vsiz),
sizeof (vsiz));
522 invec.read(charAddress(scale),
sizeof (scale));
525 invec.read(charAddress(version),
sizeof (version));
527 StdUnits = version>=2.0;
536 return StatusCode::SUCCESS;
541 std::map<int,unsigned long long> &modmap,
float &version)
544 bool StdUnits =
true;
547 return StatusCode::FAILURE;
550 std::ifstream invec(
m_pathbin+filename, std::ios::binary);
552 return StatusCode::FAILURE;
555 invec.read(charAddress(vsiz),
sizeof (vsiz));
560 invec.read(charAddress(scale),
sizeof (scale));
565 invec.read(charAddress(version),
sizeof (version));
573 for(
int i=0; i<
m_size; i++) {
574 invec.read(charAddress(ielem),
sizeof (ielem));
577 invec.read(charAddress(velem),
sizeof (velem));
585 return StatusCode::SUCCESS;
590 std::map<int,unsigned long long> &modmap,
float &version)
592 std::ifstream invec(
m_pathbin+filename, std::ios::binary);
594 return StatusCode::FAILURE;
597 invec.read(charAddress(vsiz),
sizeof (vsiz));
601 invec.read(charAddress(scale),
sizeof (scale));
604 invec.read(charAddress(version),
sizeof (version));
611 for(
int i=0; i<
m_size; i++) {
612 invec.read(charAddress(ielem),
sizeof (ielem));
615 invec.read(charAddress(velem),
sizeof (velem));
623 return StatusCode::SUCCESS;
628 std::ifstream eigenvec(filename, std::ios::binary);
630 return StatusCode::FAILURE;
633 eigenvec.read(charAddress(vsiz),
sizeof (vsiz));
637 for(
int i=0; i<
m_size; i++) {
638 eigenvec.read(charAddress(velem),
sizeof (velem));
644 return StatusCode::SUCCESS;
650 std::ofstream outvec;
654 outvec.open(
m_pathbin+filename, std::ios::binary);
657 return StatusCode::FAILURE;
659 outvec.write(charAddress(io_size),
sizeof (io_size));
665 return StatusCode::FAILURE;
667 outvec.setf(std::ios::fixed);
668 outvec.setf(std::ios::showpoint);
670 outvec <<
"AlVec::DoF: " << std::setw(6) <<
m_size << std::endl;
677 for(
int i=0; i<
m_size; i++) {
682 outvec.write(charAddress((velem)),
sizeof (velem));
684 outvec << std::setw(10) << i << std::setw(18) << velem << std::endl;
687 return StatusCode::SUCCESS;
contains the implementation of the methods of class AlMat, for handling general NxM matrices
contains the base implementation for handling symmertic matrices
void SetPathBin(const std::string &)
StatusCode Write(std::string_view, bool, double, const std::map< int, unsigned long long > &, float)
AlVec & operator+=(const AlVec &)
AlVec & operator*=(const double &)
StatusCode InitializeOutputVector(std::string_view, bool, double, float, std::ofstream &)
AlVec operator+(const AlVec &) const
int RemoveElements(std::vector< int >)
StatusCode ReadPartial(const std::string &, double &, std::map< int, unsigned long long > &, float &)
StatusCode WriteEigenvalueVec(const std::string &, bool)
AlVec & operator-=(const AlVec &)
StatusCode Read(const std::string &, double &, std::map< int, unsigned long long > &, float &)
void SetPathTxt(const std::string &)
AlVec & operator=(const AlVec &v)
StatusCode WritePartial(std::string_view, bool, double, const std::map< int, unsigned long long > &, float)
void RemoveAlignPar(int, int)
StatusCode ReadProjected(const std::string &, double &, std::map< int, unsigned long long > &, float &)
StatusCode ReadScalaPack(const std::string &)
AlVec operator-(const AlVec &) const
static StatusCode CheckVecVersion(const std::string &, bool &)
double operator*(const AlVec &) const
Ensure that the ATLAS eigen extensions are properly loaded.
std::pair< long int, long int > indices