00001 #ifndef _util_h
00002 #define _util_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "DoubleParameter.h"
00014 #include "Result.h"
00015
00016
00017
00018
00019
00020
00021 extern const ColumnVector NullPoint;
00022
00024 int Sgn(double d);
00025
00027 int CompareIntegers(int *a, int *b);
00028
00038 double QuadraticForm(const SymmetricMatrix& matrix,
00039 const ColumnVector& point);
00040
00042 void RethrowNewmatError(const BaseException& error,
00043 std::auto_ptr<Result> ap_result);
00044
00045
00046
00047
00048 wxTextOutputStream& operator<<(wxTextOutputStream& os,
00049 const BaseMatrix& X);
00050
00051 wxTextOutputStream& operator<<(wxTextOutputStream& os,
00052 const GeneralMatrix& X);
00053
00054 wxTextOutputStream& operator<<(wxTextOutputStream& os,
00055 const std::vector<int>& vect);
00056
00057
00058 wxString& operator<<(wxString& string, const ColumnVector& point);
00059
00060
00061 wxString& operator<<(wxString& string, const std::vector<int>& vect);
00062
00064 wxChar DiscoverDecimalSeparator();
00065
00067 int DigitCount(double number,
00068 bool maxAsInfinity = false);
00069
00071 int DigitCount(const GeneralMatrix& matrix,
00072 bool maxAsInfinity = false);
00073
00075 wxString MatrixNumberFormat(
00076 const GeneralMatrix& matrix,
00077 bool maxAsInfinity = false);
00078
00079
00080
00081 wxString PaddedInfinitySymbol(
00082 const GeneralMatrix& matrix);
00083
00085 template<typename T_to, typename T_from>
00086 inline std::auto_ptr<T_to> aptr_dynamic_cast(std::auto_ptr<T_from> aPointer)
00087 {
00088 auto_ptr<T_to> apNew(dynamic_cast<T_to*>(aPointer.release()));
00089
00090 return apNew;
00091 }
00092
00093 size_t RandomIndex(size_t leftIndex, size_t rightIndex);
00094
00095 double RandomDouble(double leftBound, double rightBound);
00096
00097 double RandomCauchy(double x_0, double lambda);
00098
00099 #endif // _util_h