Re: Filib++ based version of CoStLy

22 Mar
2002
22 Mar
'02
9:30 p.m.
Markus Neher wrote:
Dear Roberto,
attached is a preliminary release of CoStLy Version 0.2, based on Filib++. It has the same functionality as the old version which was based on C-XSC, but it is much faster.
Dear Markus,
thank you very much: I was looking forward to that one! I attach below a diff containing the changes I had to perform in order to use the library. The changes are rather simple: all I had to do was to fix a couple of namespace std issues and to guard the code depending on `Complex' with `#ifdef HAS_Complex'. Thanks again
Roberto
P.S. I am also having a (more semantic) problem with pow(), but I prefer to investigate further.
--
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara@cs.unipr.it
Index: cimath.cpp
===================================================================
RCS file: /cvs/purrs/purrs/CoStLy/cimath.cpp,v
retrieving revision 1.1.1.1
diff -c -d -c -4 -r1.1.1.1 cimath.cpp
*** cimath.cpp 22 Mar 2002 13:23:27 -0000 1.1.1.1
--- cimath.cpp 22 Mar 2002 21:23:25 -0000
***************
*** 76,83 ****
--- 76,86 ----
#include "Interval.h" //fi_lib++ Header: Macro Version
typedef Interval interval;
+ using std::abs;
+ using std::max;
+
inline const interval& HALFPI()
{
static const interval hp( interval::PI() / 2.0 );
return hp;
Index: cimath.h
===================================================================
RCS file: /cvs/purrs/purrs/CoStLy/cimath.h,v
retrieving revision 1.1.1.1
diff -c -d -c -4 -r1.1.1.1 cimath.h
*** cimath.h 22 Mar 2002 13:23:28 -0000 1.1.1.1
--- cimath.h 22 Mar 2002 21:23:25 -0000
***************
*** 25,33 ****
#ifndef _CIMATH_H_INCLUDED
#define _CIMATH_H_INCLUDED
! #include "cinterval.hpp"
cinterval exp(const cinterval&);
cinterval cos(const cinterval&);
cinterval sin(const cinterval&);
--- 25,33 ----
#ifndef _CIMATH_H_INCLUDED
#define _CIMATH_H_INCLUDED
! #include "cinterval.h"
cinterval exp(const cinterval&);
cinterval cos(const cinterval&);
cinterval sin(const cinterval&);
Index: cinterval.cpp
===================================================================
RCS file: /cvs/purrs/purrs/CoStLy/cinterval.cpp,v
retrieving revision 1.1.1.1
diff -c -d -c -4 -r1.1.1.1 cinterval.cpp
*** cinterval.cpp 22 Mar 2002 13:23:28 -0000 1.1.1.1
--- cinterval.cpp 22 Mar 2002 21:23:25 -0000
***************
*** 25,32 ****
--- 25,34 ----
#include "cinterval.h"
#include "error.h"
+ using std::ostream;
+
cinterval operator - (const cinterval& z)
{
return cinterval( -z.re(), -z.im() );
}
***************
*** 348,355 ****
--- 350,358 ----
{
return sqrt(sqr(z.re())+sqr(z.im()));
}
+ #ifdef HAS_Complex
Complex mid (const cinterval& z)
{
return Complex( mid(z.re()), mid(z.im()) );
}
***************
*** 357,364 ****
--- 360,368 ----
Complex diam(const cinterval& z)
{
return Complex( diam(z.re()), diam(z.im()) );
}
+ #endif
//Binary operators
cinterval operator + (const cinterval& z1, const cinterval& z2)
Index: cinterval.h
===================================================================
RCS file: /cvs/purrs/purrs/CoStLy/cinterval.h,v
retrieving revision 1.1.1.1
diff -c -d -c -4 -r1.1.1.1 cinterval.h
*** cinterval.h 22 Mar 2002 13:23:28 -0000 1.1.1.1
--- cinterval.h 22 Mar 2002 21:23:25 -0000
***************
*** 27,35 ****
--- 27,41 ----
#define CINTERVAL_H_INCLUDED
#include "Interval.h" //filib++ Header: Macro Version
#include <iostream>
+ #ifdef HAS_Complex
#include <Complex.h>
+ #endif
+
+ #ifdef FILIB_NAMESPACES
+ typedef filib::Interval Interval;
+ #endif
class cinterval
{
private:
***************
*** 43,51 ****
--- 49,59 ----
cinterval(const cinterval& z) : real_part(z.real_part), imag_part(z.imag_part) {}
explicit cinterval(const Interval& x) : real_part(x), imag_part(0.0) {}
explicit cinterval(const double& d) : real_part(d), imag_part(0.0) {}
+ #ifdef HAS_Complex
explicit cinterval(const Complex& c) : real_part(c.real()), imag_part(c.imag()) {}
+ #endif
cinterval& operator = (const cinterval& z)
{
if( this == &z ) return *this;
***************
*** 91,101 ****
inline const Interval& Re(const cinterval& z) { return z.re(); }
inline const Interval& Im(const cinterval& z) { return z.im(); }
Interval abs (const cinterval&);
Complex mid (const cinterval&);
Complex diam(const cinterval&);
!
cinterval operator - (const cinterval&);
// cinterval o cinterval, o \in { +,-,* }.
--- 99,110 ----
inline const Interval& Re(const cinterval& z) { return z.re(); }
inline const Interval& Im(const cinterval& z) { return z.im(); }
Interval abs (const cinterval&);
+ #ifdef HAS_Complex
Complex mid (const cinterval&);
Complex diam(const cinterval&);
! #endif
cinterval operator - (const cinterval&);
// cinterval o cinterval, o \in { +,-,* }.
***************
*** 133,141 ****
cinterval operator / (const cinterval&, const double&);
// output
! ostream& operator << (ostream&, const cinterval&);
//
bool operator <= (const double&, const cinterval&);
--- 142,150 ----
cinterval operator / (const cinterval&, const double&);
// output
! std::ostream& operator << (std::ostream&, const cinterval&);
//
bool operator <= (const double&, const cinterval&);
Index: error.h
===================================================================
RCS file: /cvs/purrs/purrs/CoStLy/error.h,v
retrieving revision 1.1.1.1
diff -c -d -c -4 -r1.1.1.1 error.h
*** error.h 22 Mar 2002 13:23:28 -0000 1.1.1.1
--- error.h 22 Mar 2002 21:23:25 -0000
***************
*** 27,53 ****
#define _ERROR_H_INCLUDED
#include <stdexcept>
! class syntax_error : public logic_error
{
public:
! syntax_error(const string& what_arg) : logic_error(what_arg) {}
};
! class division_by_zero : public logic_error
{
public:
division_by_zero() : logic_error("") {}
};
! class function_not_defined : public invalid_argument
{
public:
function_not_defined() : invalid_argument("") {}
};
! class wrong_dimensions : public length_error
{
public:
wrong_dimensions() : length_error("") {}
};
--- 27,53 ----
#define _ERROR_H_INCLUDED
#include <stdexcept>
! class syntax_error : public std::logic_error
{
public:
! syntax_error(const std::string& what_arg) : logic_error(what_arg) {}
};
! class division_by_zero : public std::logic_error
{
public:
division_by_zero() : logic_error("") {}
};
! class function_not_defined : public std::invalid_argument
{
public:
function_not_defined() : invalid_argument("") {}
};
! class wrong_dimensions : public std::length_error
{
public:
wrong_dimensions() : length_error("") {}
};
8446
Age (days ago)
8446
Last active (days ago)
0 comments
1 participants
participants (1)
-
Roberto Bagnara