6 #ifndef THEORETICA_UTILITY_H
7 #define THEORETICA_UTILITY_H
19 template<
typename Type>
20 inline void print(
const Type& curr) {
26 template<
typename Type,
typename ...Args>
27 inline void print(
const Type& curr, Args... args) {
28 std::cout << curr <<
" ";
33 template<
typename Type>
34 inline void fprint(std::ostream& out,
const Type& last) {
40 template<
typename Type,
typename ...Args>
41 inline void fprint(std::ostream& out,
const Type& curr, Args... args) {
54 template<
typename Type>
56 std::cout << curr <<
"\n";
61 template<
typename Type,
typename ...Args>
62 inline void println(
const Type& curr, Args... args) {
63 std::cout << curr <<
" ";
69 template<
typename Type>
70 inline void fprintln(std::ostream& out,
const Type& curr) {
76 template<
typename Type,
typename ...Args>
77 inline void fprintln(std::ostream& out,
const Type& curr, Args... args) {
87 template<
typename Type = real>
90 const std::string& terminator,
91 std::function<Type(std::string)> parse) {
99 std::getline(in, line);
102 if(line == terminator)
113 std::cout <<
"Input conversion error" << std::endl;
129 std::istream& in,
const std::string& terminator =
"") {
131 return readln<real>(in, terminator, [](std::string line) {
132 std::replace(line.begin(), line.end(),
',',
'.');
133 return std::stod(line);
143 return readln(std::cin, terminator);
A statically allocated N-dimensional vector with elements of the given type.
Definition: vec.h:92
Main namespace of the library which contains all functions and objects.
Definition: algebra.h:27
void fprint(std::ostream &out, const Type &last)
Print the given argument to a stream.
Definition: utility.h:34
void println()
Print a newline to standard output.
Definition: utility.h:48
void fprintln(std::ostream &out, const Type &curr)
Print the given argument to an output stream followed by a newline.
Definition: utility.h:70
void print(const Type &curr)
Print the given argument to standard output.
Definition: utility.h:20
vec< Type > readln(std::istream &in, const std::string &terminator, std::function< Type(std::string)> parse)
Insert a data set of the given type from a stream, reading line by line until a line is equal to the ...
Definition: utility.h:88
Vector class and operations.