Ignore:
Timestamp:
12/03/14 11:37:24 (10 years ago)
Author:
Mathieu Morlighem
Message:

NEW: added covertree nearest neighbor search (to be debugged)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/kriging/Observation.cpp

    r18237 r18912  
    44
    55#include <stdlib.h>
     6#include <cmath>
     7#include <utility>
    68#include "../classes.h"
    79
     
    2325}
    2426/*}}}*/
     27Observation::Observation(double x_in, double y_in,double value_in){
     28        this->x = x_in;
     29        this->y = y_in;
     30        this->value = value_in;
     31
     32        this->xi     = 0;
     33        this->yi     = 0;
     34        this->index  = 0;
     35        this->weight = 0.;
     36}
    2537Observation::~Observation(){/*{{{*/
    2638        return;
     
    5971}
    6072/*}}}*/
     73
     74/*Covertree*/
     75void Observation::print(void) const{/*{{{*/
     76
     77        _printf_("Observation\n");
     78        _printf_("   x     : " << this->x << "\n");
     79        _printf_("   y     : " << this->y << "\n");
     80        _printf_("   value : " << this->value << "\n");
     81}
     82/*}}}*/
     83double Observation::distance(const Observation& ob) const
     84{
     85        return std::sqrt( (std::pow( (ob.getXY().first - this->x), 2 ) + std::pow((ob.getXY().second - this->y), 2) ));
     86}
     87
     88const std::pair<double, double>& Observation::getXY() const
     89{
     90        return std::make_pair(this->x, this->y);
     91}
     92bool Observation::operator==(const Observation& ob) const
     93{
     94        return (ob.getXY().first == this->x && ob.getXY().second == this->y && ob.value == this->value);
     95}
     96
     97void Observation::WriteXYObs(const Observation& ob, double* px, double* py, double* pobs){
     98    *px   = ob.getXY().first;
     99    *py   = ob.getXY().second;
     100    *pobs = ob.value;
     101}
Note: See TracChangeset for help on using the changeset viewer.