8#include "idol/general/utils/SparseVector.h"
9#include "idol/general/utils/IteratorForward.h"
10#include "idol/general/utils/exceptions/Exception.h"
20 template<
class KeyT,
class ValueT>
27template<
class KeyT =
idol::Var,
class ValueT =
double>
33 LinExpr(
const ValueT& t_factor,
const KeyT& t_key);
34 LinExpr(ValueT&& t_factor,
const KeyT& t_key);
43 LinExpr& operator+=(
const KeyT& t_rhs);
46 LinExpr& operator-=(
const KeyT& t_rhs);
53template<
class KeyT,
class ValueT>
55 SparseVector<KeyT, ValueT>::operator-=(SparseVector<KeyT, ValueT>(t_rhs, 1));
59template<
class KeyT,
class ValueT>
61 SparseVector<KeyT, ValueT>::operator-=((SparseVector<KeyT, ValueT>&) t_rhs);
65template<
class KeyT,
class ValueT>
67 SparseVector<KeyT, ValueT>::operator+=(SparseVector<KeyT, ValueT>(t_rhs, 1));
71template<
class Key,
class ValueT>
73 SparseVector<Key, ValueT>::operator+=((SparseVector<Key, ValueT>&) t_rhs);
77template<
class Key,
class ValueT>
82template<
class Key,
class ValueT>
87template<
class Key,
class ValueT>
92 template<
class KeyT,
class ValueT>
93 std::ostream& operator<<(std::ostream& t_os,
const LinExpr<KeyT, ValueT>& t_expr) {
99 auto it = t_expr.begin();
100 if constexpr (std::is_same_v<ValueT, double>) {
105 t_os <<
"[ " << it->second <<
" ] " << it->first;
108 for (
const auto end = t_expr.end() ; it != end ; ++it) {
110 if constexpr (std::is_same_v<ValueT, double>) {
111 t_os << it->second <<
" " << it->first;
113 t_os <<
"[ " << it->second <<
" ] " << it->first;