#ifndef LOGREG_HPP
#define LOGREG_HPP

#include <math.h>
#include <vector>

class Logreg
{
  public:
    Logreg();

    void train();
    void add_measurement(double phase, bool positive);

  private:

    class Vec3D {
      public:
        double x,y,z;
        Vec3D(double x_, double y_, double z_) :
          x(x_),
          y(y_),
          z(z_)
        {

        }

        Vec3D operator *(double s) const {
          return Vec3D(x*s, y*s, z*s);
        }

        double operator *(Vec3D v) const {
          return x*v.x + y*v.y + z*v.z;
        }

        Vec3D operator +(Vec3D v) const {
          return Vec3D(x+v.x, y+v.y, z+v.z);
        }
        Vec3D operator +=(Vec3D v) {
          x += v.x;
          y += v.y;
          z += v.z;
          return *this;
        }
        Vec3D operator -(Vec3D v) const {
          return Vec3D(x-v.x, y-v.y, z-v.z);
        }
        Vec3D operator -=(Vec3D v) {
          x -= v.x;
          y -= v.y;
          z -= v.z;
          return *this;
        }

        double norm() const {
          return sqrt(x*x + y*y + z*z);
        }
    };

    Vec3D w;

    class Measurement {
      public:
        Measurement(Vec3D x_, double y_) :
          x(x_),
          y(y_)
        {

        }
        Vec3D x;
        double y;
    };

    std::vector<Measurement> points;

    double loss(Vec3D at) const;
    Vec3D gradient(Vec3D at) const;

};

#endif // LOGREG_HPP
