20 #ifndef SELDON_FILE_ERRORS_CXX
44 description_(
"ERROR!\nAn undefined error occurred"),
45 function_(function), comment_(comment)
47 #ifdef SELDON_WITH_ABORT
61 description_(
"ERROR!\n" + description),
62 function_(function), comment_(comment)
108 #ifdef SELDON_WITH_MPI
109 int rank_proc; MPI_Comm_rank(MPI_COMM_WORLD, &rank_proc);
110 cout <<
"Error on processor " << rank_proc << endl;
113 cout << this->
What() << endl;
115 #ifdef SELDON_WITH_MPI
121 MPI_Barrier(MPI_COMM_WORLD);
138 Error(
"", function, comment)
140 #ifdef SELDON_WITH_ABORT
163 message =
"A function or a method";
164 message +=
" is undefined.\nEither its implementation is missing,"
165 + string(
" or it does not make sense or it is impossible ")
166 +
"to implement it.\n";
184 Error(
"Wrong argument given to ", function, comment)
186 #ifdef SELDON_WITH_ABORT
226 Error(
"Out of memory", function, comment)
228 #ifdef SELDON_WITH_ABORT
252 Error(
"Wrong dimensions involved", function, comment)
254 #ifdef SELDON_WITH_ABORT
278 Error(
"Index out of range", function, comment)
280 #ifdef SELDON_WITH_ABORT
304 Error(
"Row index out of range", function, comment)
306 #ifdef SELDON_WITH_ABORT
330 Error(
"Column index out of range", function, comment)
332 #ifdef SELDON_WITH_ABORT
356 Error(
"Error while performing an I/O operation", function, comment)
358 #ifdef SELDON_WITH_ABORT
382 Error(
"Maximum number of iterations reached by the solver", function, comment)
399 Error(
"Maximum number of iterations reached by the solver", function, comment)
415 void CheckBounds(
long i,
long length1_,
string nom)
417 if (i < 0 || i >= length1_)
419 string(
"Index along dimension #1 should be in [0, ")
420 +
to_str(length1_-1) +
"], but is equal to "
425 void CheckBounds(
int i,
int j,
int length1_,
int length2_,
string nom)
427 if (i < 0 || i >= length1_)
428 throw WrongIndex(nom +
"::operator()",
429 string(
"Index along dimension #1 should be in [0, ")
430 +
to_str(length1_-1) +
"], but is equal to "
432 if (j < 0 || j >= length2_)
433 throw WrongIndex(nom +
"::operator()",
434 string(
"Index along dimension #2 should be in [0, ")
435 +
to_str(length2_-1) +
"], but is equal to "
440 void CheckBoundsSym(
int i,
int j,
int length1_,
int length2_,
string nom)
442 CheckBounds(i, j, length1_, length2_, nom);
445 throw WrongRow(nom+
"::Val(int, int)",
446 string(
"Attempted to access to element (")
448 +
") but row index should not be strictly"
449 +
" greater than column index.");
453 void CheckBoundsTriang(
int i,
int j,
int length1_,
int length2_,
454 bool uplo,
string nom)
456 CheckBounds(i, j, length1_, length2_, nom);
461 throw WrongRow(nom +
"::Val(int, int)",
462 string(
"Attempted to access to element (")
464 +
string(
" index should not be strictly more")
465 +
" than column index (upper triangular matrix).");
470 throw WrongCol(nom +
"::Val(int, int)",
471 string(
"Attempted to access to element (")
473 +
string(
" column index should not be strictly more")
474 +
" than row index (lower triangular matrix).");
479 void CheckBounds(
int i,
int j,
int k,
480 int length1_,
int length2_,
int length3_,
string nom)
482 if (i < 0 || i >= length1_)
483 throw WrongIndex(nom +
"::operator()",
484 string(
"Index along dimension #1 should be in [0, ")
485 +
to_str(length1_-1) +
"], but is equal to "
487 if (j < 0 || j >= length2_)
488 throw WrongIndex(nom +
"::operator()",
489 string(
"Index along dimension #2 should be in [0, ")
490 +
to_str(length2_-1) +
"], but is equal to "
492 if (k < 0 || k >= length3_)
493 throw WrongIndex(nom +
"::operator()",
494 string(
"Index along dimension #3 should be in [0, ")
495 +
to_str(length3_-1) +
"], but is equal to "
500 void CheckBounds(
int i,
int j,
int k,
int l,
int length1_,
int length2_,
501 int length3_,
int length4_,
string nom)
503 if (i < 0 || i >= length1_)
504 throw WrongIndex(nom +
"::operator()",
505 string(
"Index along dimension #1 should be in [0, ")
506 +
to_str(length1_-1) +
"], but is equal to "
508 if (j < 0 || j >= length2_)
509 throw WrongIndex(nom +
"::operator()",
510 string(
"Index along dimension #2 should be in [0, ")
511 +
to_str(length2_-1) +
"], but is equal to "
513 if (k < 0 || k >= length3_)
514 throw WrongIndex(nom +
"::operator()",
515 string(
"Index along dimension #3 should be in [0, ")
516 +
to_str(length3_-1) +
"], but is equal to "
518 if (l < 0 || l >= length4_)
519 throw WrongIndex(nom +
"::operator()",
520 string(
"Index along dimension #4 should be in [0, ")
521 +
to_str(length4_-1) +
"], but is equal to "
526 void CheckBounds(
int i,
int j,
int k,
int l,
int m,
527 int length0,
int length1,
int length2,
int length3,
528 int length4,
string nom)
530 if (i < 0 || i >= length0)
531 throw WrongIndex(nom+
"::operator()",
532 string(
"Index along dimension #1 should be in [0, ")
533 +
to_str(length0 - 1) +
"], but is equal to "
535 if (j < 0 || j >= length1)
536 throw WrongIndex(nom+
"::operator()",
537 string(
"Index along dimension #2 should be in [0, ")
538 +
to_str(length1 - 1) +
"], but is equal to "
540 if (k < 0 || k >= length2)
541 throw WrongIndex(nom+
"::operator()",
542 string(
"Index along dimension #3 should be in [0, ")
543 +
to_str(length2 - 1) +
"], but is equal to "
545 if (l < 0 || l >= length3)
546 throw WrongIndex(nom+
"::operator()",
547 string(
"Index along dimension #4 should be in [0, ")
548 +
to_str(length3 - 1) +
"], but is equal to "
550 if (m < 0 || m >= length4)
551 throw WrongIndex(nom+
"::operator()",
552 string(
"Index along dimension #5 should be in [0, ")
553 +
to_str(length4 - 1) +
"], but is equal to "
558 void CheckBounds(
int i,
int j,
int k,
int l,
int m,
int n,
559 int length0,
int length1,
int length2,
int length3,
560 int length4,
int length5,
string nom)
562 if (i < 0 || i >= length0)
563 throw WrongIndex(nom+
"::operator()",
564 string(
"Index along dimension #1 should be in [0, ")
565 +
to_str(length0 - 1) +
"], but is equal to "
567 if (j < 0 || j >= length1)
568 throw WrongIndex(nom+
"::operator()",
569 string(
"Index along dimension #2 should be in [0, ")
570 +
to_str(length1 - 1) +
"], but is equal to "
572 if (k < 0 || k >= length2)
573 throw WrongIndex(nom+
"::operator()",
574 string(
"Index along dimension #3 should be in [0, ")
575 +
to_str(length2 - 1) +
"], but is equal to "
577 if (l < 0 || l >= length3)
578 throw WrongIndex(nom+
"::operator()",
579 string(
"Index along dimension #4 should be in [0, ")
580 +
to_str(length3 - 1) +
"], but is equal to "
582 if (m < 0 || m >= length4)
583 throw WrongIndex(nom+
"::operator()",
584 string(
"Index along dimension #5 should be in [0, ")
585 +
to_str(length4 - 1) +
"], but is equal to "
587 if (n < 0 || n >= length5)
588 throw WrongIndex(nom+
"::operator()",
589 string(
"Index along dimension #6 should be in [0, ")
590 +
to_str(length5 - 1) +
"], but is equal to "
595 void CheckBounds(
int i,
int j,
int k,
int l,
int m,
int n,
int o,
596 int length0,
int length1,
int length2,
int length3,
597 int length4,
int length5,
int length6,
string nom)
599 if (i < 0 || i >= length0)
600 throw WrongIndex(nom+
"::operator()",
601 string(
"Index along dimension #1 should be in [0, ")
602 +
to_str(length0 - 1) +
"], but is equal to "
604 if (j < 0 || j >= length1)
605 throw WrongIndex(nom+
"::operator()",
606 string(
"Index along dimension #2 should be in [0, ")
607 +
to_str(length1 - 1) +
"], but is equal to "
609 if (k < 0 || k >= length2)
610 throw WrongIndex(nom+
"::operator()",
611 string(
"Index along dimension #3 should be in [0, ")
612 +
to_str(length2 - 1) +
"], but is equal to "
614 if (l < 0 || l >= length3)
615 throw WrongIndex(nom+
"::operator()",
616 string(
"Index along dimension #4 should be in [0, ")
617 +
to_str(length3 - 1) +
"], but is equal to "
619 if (m < 0 || m >= length4)
620 throw WrongIndex(nom+
"::operator()",
621 string(
"Index along dimension #5 should be in [0, ")
622 +
to_str(length4 - 1) +
"], but is equal to "
624 if (n < 0 || n >= length5)
625 throw WrongIndex(nom+
"::operator()",
626 string(
"Index along dimension #6 should be in [0, ")
627 +
to_str(length5 - 1) +
"], but is equal to "
629 if (o < 0 || o >= length6)
630 throw WrongIndex(nom+
"::operator()",
631 string(
"Index along dimension #7 should be in [0, ")
632 +
to_str(length6 - 1) +
"], but is equal to "
637 void CheckBounds(
int i,
int j,
int k,
int l,
int m,
int n,
int o,
int p,
638 int length0,
int length1,
int length2,
int length3,
639 int length4,
int length5,
int length6,
int length7,
642 if (i < 0 || i >= length0)
643 throw WrongIndex(nom+
"::operator()",
644 string(
"Index along dimension #1 should be in [0, ")
645 +
to_str(length0 - 1) +
"], but is equal to "
647 if (j < 0 || j >= length1)
648 throw WrongIndex(nom+
"::operator()",
649 string(
"Index along dimension #2 should be in [0, ")
650 +
to_str(length1 - 1) +
"], but is equal to "
652 if (k < 0 || k >= length2)
653 throw WrongIndex(nom+
"::operator()",
654 string(
"Index along dimension #3 should be in [0, ")
655 +
to_str(length2 - 1) +
"], but is equal to "
657 if (l < 0 || l >= length3)
658 throw WrongIndex(nom+
"::operator()",
659 string(
"Index along dimension #4 should be in [0, ")
660 +
to_str(length3 - 1) +
"], but is equal to "
662 if (m < 0 || m >= length4)
663 throw WrongIndex(nom+
"::operator()",
664 string(
"Index along dimension #5 should be in [0, ")
665 +
to_str(length4 - 1) +
"], but is equal to "
667 if (n < 0 || n >= length5)
668 throw WrongIndex(nom+
"::operator()",
669 string(
"Index along dimension #6 should be in [0, ")
670 +
to_str(length5 - 1) +
"], but is equal to "
672 if (o < 0 || o >= length6)
673 throw WrongIndex(nom+
"::operator()",
674 string(
"Index along dimension #7 should be in [0, ")
675 +
to_str(length6 - 1) +
"], but is equal to "
677 if (p < 0 || p >= length7)
678 throw WrongIndex(nom+
"::operator()",
679 string(
"Index along dimension #8 should be in [0, ")
680 +
to_str(length7 - 1) +
"], but is equal to "
685 void CheckBounds(
int i,
int j,
int k,
int l,
int m,
int n,
int o,
int p,
686 int q,
int length0,
int length1,
int length2,
int length3,
687 int length4,
int length5,
int length6,
int length7,
688 int length8,
string nom)
690 if (i < 0 || i >= length0)
691 throw WrongIndex(nom+
"::operator()",
692 string(
"Index along dimension #1 should be in [0, ")
693 +
to_str(length0 - 1) +
"], but is equal to "
695 if (j < 0 || j >= length1)
696 throw WrongIndex(nom+
"::operator()",
697 string(
"Index along dimension #2 should be in [0, ")
698 +
to_str(length1 - 1) +
"], but is equal to "
700 if (k < 0 || k >= length2)
701 throw WrongIndex(nom+
"::operator()",
702 string(
"Index along dimension #3 should be in [0, ")
703 +
to_str(length2 - 1) +
"], but is equal to "
705 if (l < 0 || l >= length3)
706 throw WrongIndex(nom+
"::operator()",
707 string(
"Index along dimension #4 should be in [0, ")
708 +
to_str(length3 - 1) +
"], but is equal to "
710 if (m < 0 || m >= length4)
711 throw WrongIndex(nom+
"::operator()",
712 string(
"Index along dimension #5 should be in [0, ")
713 +
to_str(length4 - 1) +
"], but is equal to "
715 if (n < 0 || n >= length5)
716 throw WrongIndex(nom+
"::operator()",
717 string(
"Index along dimension #6 should be in [0, ")
718 +
to_str(length5 - 1) +
"], but is equal to "
720 if (o < 0 || o >= length6)
721 throw WrongIndex(nom+
"::operator()",
722 string(
"Index along dimension #7 should be in [0, ")
723 +
to_str(length6 - 1) +
"], but is equal to "
725 if (p < 0 || p >= length7)
726 throw WrongIndex(nom+
"::operator()",
727 string(
"Index along dimension #8 should be in [0, ")
728 +
to_str(length7 - 1) +
"], but is equal to "
730 if (q < 0 || q >= length8)
731 throw WrongIndex(nom+
"::operator()",
732 string(
"Index along dimension #9 should be in [0, ")
733 +
to_str(length8 - 1) +
"], but is equal to "
738 void CheckPointer(
void* ptr,
string name)
741 throw WrongArgument(name,
"Pointer is null");
757 Error(
"Error returned by Lapack", function, comment), info_(info)
759 #ifdef SELDON_WITH_ABORT
784 message +=
" Diagnostic integer (\"info\"): " +
to_str(info_)
795 LapackInfo::LapackInfo(
int info): info_(info)
800 LapackInfo::operator int ()
806 int LapackInfo::GetInfo()
812 int& LapackInfo::GetInfoRef()
818 #ifndef SELDON_WITH_COMPILED_LIBRARY
819 LapackInfo lapack_info(0);
825 #define SELDON_FILE_ERRORS_CXX
virtual string What()
Delivers information about the error.
virtual ~Undefined()
Destructor (present to avoid duplicate symbols in .o files)
virtual ~SolverMaximumIterationError()
Destructor (present to avoid duplicate symbols in .o files)
Undefined(string function="", string comment="")
Main constructor.
string comment_
A comment about the error.
virtual ~IOError()
Destructor (present to avoid duplicate symbols in .o files)
std::string to_str(const T &input)
Converts most types to string.
WrongCol(string function="", string comment="")
Main constructor.
virtual ~SolverDivergenceError()
Destructor (present to avoid duplicate symbols in .o files)
SolverDivergenceError(string function="", string comment="")
Main constructor.
virtual ~WrongIndex()
Destructor (present to avoid duplicate symbols in .o files)
void CoutWhat()
Delivers information about the error.
virtual ~Error()
Destructor.
WrongRow(string function="", string comment="")
Main constructor.
virtual ~WrongRow()
Destructor (present to avoid duplicate symbols in .o files)
WrongIndex(string function="", string comment="")
Main constructor.
string description_
Message describing the exception type.
virtual string What()
Delivers information about the error.
LapackError(int info, string function, string comment)
Main constructor.
virtual ~NoMemory()
Destructor (present to avoid duplicate symbols in .o files)
NoMemory(string function="", string comment="")
Main constructor.
virtual ~WrongCol()
Destructor (present to avoid duplicate symbols in .o files)
virtual string What()
Delivers information about the error.
string function_
Name of the function in which the error occurred.
Error(string function="", string comment="")
Main constructor.
virtual ~LapackError()
Destructor (present to avoid duplicate symbols in .o files)
IOError(string function="", string comment="")
Main constructor.
SolverMaximumIterationError(string function="", string comment="")
Main constructor.
virtual string What()
Delivers information about the error.
virtual ~WrongArgument()
Destructor (present to avoid duplicate symbols in .o files)
virtual ~WrongDim()
Destructor (present to avoid duplicate symbols in .o files)
WrongDim(string function="", string comment="")
Main constructor.
WrongArgument(string function="", string comment="")
Main constructor.