/* 
 * File:   method.h
 * Author: Andréa
 *
 * Created on 15 octobre 2010, 15:35
 */

#ifndef METHOD_H
#define	METHOD_H

#include "constants.h"
#include "utilities.h"
#include "problema.h"

#include "logger.h"

#define DEFAULT_EPSILON        0.000001
#define DEFAULT_MAX_ITERATION  100000

typedef struct _method
{
    //data
    unsigned long _db_id;
    char          _name[MAX_INPUT];
    void       (* _method_function)
                    (
                        Problema*       pb,
                        struct _method* m,
                        double          init_vector[],
                        void*           args[]
                    );

    // précision
    double        _epsilon_in;
    double        _epsilon_out;
    unsigned int  _max_iteration;

    // data buffer
    double*       _last_result;
    double        _last_result_function_value;
    unsigned int  _last_absolute_error;
    double        _last_relative_error;
    unsigned int  _last_complexity;

} Method;

Method* createMethod();

Method* createMethodWithParameters(
    char*         methodName,
    unsigned long methodId,
    void       (* method_function)
                (
                    Problema*       pb,
                    Method*         method,
                    double          init_vector[],
                    void*           args[]
                )
);

void destroyMethod(Method **);

void clearResult(Method* m);

void displayResult(Method* m);
#endif	/* METHOD_H */

