9 typedef vector<double> DblVec;
10 typedef vector<unsigned char> BoolVec;
12 inline double vecSum(
const DblVec& v) {
14 for (
int i=0; i < v.size(); ++i) out += v[i];
17 inline double vecAbsSum(
const DblVec& v) {
19 for (
int i=0; i < v.size(); ++i) out += fabs(v[i]);
22 inline double pospart(
double x) {
23 return (x > 0) ? x : 0;
25 inline double sq(
double x) {
28 inline double vecHingeSum(
const DblVec& v) {
30 for (
int i=0; i < v.size(); ++i) out += pospart(v[i]);
33 inline double vecMax(
const DblVec& v) {
34 return *std::max_element(v.begin(), v.end());
36 inline double vecDot(
const DblVec& a,
const DblVec& b) {
37 assert(a.size() == b.size());
39 for (
int i=0; i < a.size(); ++i) out += a[i]*b[i];