00001 #ifndef INDII_ML_AUX_ALMOST2NORM_HPP
00002 #define INDII_ML_AUX_ALMOST2NORM_HPP
00003
00004 #include "Norm.hpp"
00005
00006 namespace indii {
00007 namespace ml {
00008 namespace aux {
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 class Almost2Norm : public Norm {
00025 public:
00026
00027
00028
00029 virtual ~Almost2Norm();
00030
00031 virtual double operator()(const vector& x) const;
00032
00033 virtual vector sample(const unsigned int N) const;
00034
00035 private:
00036
00037
00038
00039 template<class Archive>
00040 void serialize(Archive& ar, const unsigned int version);
00041
00042
00043
00044
00045 friend class boost::serialization::access;
00046
00047 };
00048
00049 }
00050 }
00051 }
00052
00053 #include "Random.hpp"
00054 #include "vector.hpp"
00055
00056 #include <set>
00057
00058 using namespace indii::ml::aux;
00059
00060 inline double indii::ml::aux::Almost2Norm::operator()(const vector& x)
00061 const {
00062 return inner_prod(x,x);
00063 }
00064
00065 inline indii::ml::aux::vector indii::ml::aux::Almost2Norm::sample(
00066 const unsigned int N) const {
00067 return Random::unitVector(N);
00068 }
00069
00070 template<class Archive>
00071 void indii::ml::aux::Almost2Norm::serialize(Archive& ar,
00072 const unsigned int version) {
00073 ar & boost::serialization::base_object<Norm>(*this);
00074 }
00075
00076 #endif
00077