Compile MTL with upcoming Sun Studio C++ 11 and upcoming patch for Sun Studio C++ 10
Simon Atanasyan <[email protected]> Fri, 19 Aug 2005 14:47:52 +0400
| Newsgroups | gmane.comp.lib.mtl.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, I'd like to suggest patch that makes MTL compatible with upcoming "Sun Studio C++ 11" and upcoming patch for "Sun Studio C++ 10". Most of fixes explicitly mark some maths functions (sqrt, rand, etc) that they come form std namespace. Another part of fixes remove some outdated "ifdef" pragmas related to __SUNPRO_CC. And the last fix turns on support of Sun C++ in configure.in With this patch I've successfully build all tests and examples and run test suite. -- Simon Atanasyan _______________________________________________ This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/
mtl-2.1.2-22.patch
(text/plain, 11.7 KB)
diff -c3 -r mtl-2.1.2-22.orig/configure.in mtl-2.1.2-22/configure.in
*** mtl-2.1.2-22.orig/configure.in Fri Feb 18 14:17:34 2005
--- mtl-2.1.2-22/configure.in Thu Aug 18 05:18:38 2005
***************
*** 49,57 ****
if test $compiler = "none"; then AC_PROG_CXX_MWERKS ; fi
if test $compiler = "none"; then AC_PROG_CXX_INTELCC ; fi
if test $compiler = "none"; then AC_PROG_CXX_MSVCPP ; fi
!
! dnl Don't bother checking for this
! dnl if test $compiler = "none"; then AC_PROG_CXX_SUNCC ; fi
BACKEND=""
MATHLIB=""
--- 49,55 ----
if test $compiler = "none"; then AC_PROG_CXX_MWERKS ; fi
if test $compiler = "none"; then AC_PROG_CXX_INTELCC ; fi
if test $compiler = "none"; then AC_PROG_CXX_MSVCPP ; fi
! if test $compiler = "none"; then AC_PROG_CXX_SUNCC ; fi
BACKEND=""
MATHLIB=""
***************
*** 110,115 ****
--- 108,121 ----
CXX_DEBUG_FLAGS="-g"
CXXLD="mwld"
;;
+ suncc*) # Sun Pro C++ http://www.sun.com
+ echo "Configuring for Sun Pro C++"
+ CXX_PICKY_FLAGS="-library=stlport4"
+ AC_BZ_SET_COMPILER($withval,"CC","$CXX_PICKY_FLAGS")
+ CXX_OPTIMIZE_FLAGS="-O"
+ CXX_DEBUG_FLAGS="-g"
+ CXXLD="$CXX"
+ ;;
*)
CXXLD="$CXX"
AC_MSG_WARN([Compiler not recognized])
diff -c3 -r mtl-2.1.2-22.orig/contrib/examples/lu_solve.cc mtl-2.1.2-22/contrib/examples/lu_solve.cc
*** mtl-2.1.2-22.orig/contrib/examples/lu_solve.cc Tue Jul 5 08:11:50 2005
--- mtl-2.1.2-22/contrib/examples/lu_solve.cc Thu Aug 18 05:18:28 2005
***************
*** 40,46 ****
double max_error = 0.0;
for(Matrix::iterator i = AInvA.begin(); i != AInvA.end(); ++i)
for(Matrix::Row::iterator j = (*i).begin(); j != (*i).end(); ++j)
! if(fabs(*j) > fabs(max_error))
max_error = *j;
std::cout << "max error = " << max_error << std::endl;
--- 40,46 ----
double max_error = 0.0;
for(Matrix::iterator i = AInvA.begin(); i != AInvA.end(); ++i)
for(Matrix::Row::iterator j = (*i).begin(); j != (*i).end(); ++j)
! if(std::fabs(*j) > std::fabs(max_error))
max_error = *j;
std::cout << "max error = " << max_error << std::endl;
diff -c3 -r mtl-2.1.2-22.orig/contrib/examples/max_index.cc mtl-2.1.2-22/contrib/examples/max_index.cc
*** mtl-2.1.2-22.orig/contrib/examples/max_index.cc Tue Jul 5 08:11:50 2005
--- mtl-2.1.2-22/contrib/examples/max_index.cc Thu Aug 18 05:18:28 2005
***************
*** 62,68 ****
int imax = max_index(x);
//end
! #if !defined(_MSVCPP_) && !defined(__sgi) || defined(__GNUC__)
// VC++ and SGI CC do not have operator << defined for complex numbers
print_vector(x);
#endif
--- 62,68 ----
int imax = max_index(x);
//end
! #if !defined(_MSVCPP_) && !defined(__sgi) || defined(__GNUC__) || defined(__SUNPRO_CC)
// VC++ and SGI CC do not have operator << defined for complex numbers
print_vector(x);
#endif
diff -c3 -r mtl-2.1.2-22.orig/mtl/abs.h mtl-2.1.2-22/mtl/abs.h
*** mtl-2.1.2-22.orig/mtl/abs.h Tue Jul 5 08:11:49 2005
--- mtl-2.1.2-22/mtl/abs.h Thu Aug 18 05:18:28 2005
***************
*** 25,36 ****
}
#endif
- #ifdef __SUNPRO_CC //sigh
- namespace std {
- inline int abs(int a) {
- return a > 0 ? a : -a;
- }
- }
- #endif
-
#endif
--- 25,28 ----
diff -c3 -r mtl-2.1.2-22.orig/mtl/entry.h mtl-2.1.2-22/mtl/entry.h
*** mtl-2.1.2-22.orig/mtl/entry.h Tue Jul 5 08:11:49 2005
--- mtl-2.1.2-22/mtl/entry.h Thu Aug 18 05:18:28 2005
***************
*** 205,211 ****
};
! #if (__GNUC__ < 9) /* let the conversion operator handle all these ops */
template <class T>
std::ostream& operator<<(std::ostream& os, const elt_ref<T>& er) {
--- 205,211 ----
};
! #if defined(__SUNPRO_CC) || (__GNUC__ < 9) /* let the conversion operator handle all these ops */
template <class T>
std::ostream& operator<<(std::ostream& os, const elt_ref<T>& er) {
diff -c3 -r mtl-2.1.2-22.orig/mtl/meta_if.h mtl-2.1.2-22/mtl/meta_if.h
*** mtl-2.1.2-22.orig/mtl/meta_if.h Tue Jul 5 08:11:49 2005
--- mtl-2.1.2-22/mtl/meta_if.h Thu Aug 18 05:18:28 2005
***************
*** 24,31 ****
namespace mtl {
! //sun workshop 6 update 2 did not handle partial specialized IF
! #if (MTL_PARTIAL_SPEC) && (!defined __SUNPRO_CC)
template <int cond, class A, class B>
struct IF { };
--- 24,30 ----
namespace mtl {
! #if (MTL_PARTIAL_SPEC)
template <int cond, class A, class B>
struct IF { };
diff -c3 -r mtl-2.1.2-22.orig/mtl/mtl.h mtl-2.1.2-22/mtl/mtl.h
*** mtl-2.1.2-22.orig/mtl/mtl.h Tue Jul 5 08:11:49 2005
--- mtl-2.1.2-22/mtl/mtl.h Thu Aug 18 05:18:28 2005
***************
*** 252,259 ****
{
typedef typename Vector::value_type T;
typedef typename number_traits<T>::magnitude_type M;
! using std::sqrt;
! return ::sqrt(mtl_algo::accumulate(x.begin(), x.end(), M(), sqr_add()));
}
#if USE_BLAIS
--- 252,258 ----
{
typedef typename Vector::value_type T;
typedef typename number_traits<T>::magnitude_type M;
! return std::sqrt(mtl_algo::accumulate(x.begin(), x.end(), M(), sqr_add()));
}
#if USE_BLAIS
***************
*** 263,270 ****
{
typedef typename Vector::value_type T;
typedef typename number_traits<T>::magnitude_type M;
! using std::sqrt;
! return ::sqrt(fast::accumulate(x.begin(), fast::count<N>(), M(), sqr_add()));
}
#endif
--- 262,268 ----
{
typedef typename Vector::value_type T;
typedef typename number_traits<T>::magnitude_type M;
! return std::sqrt(fast::accumulate(x.begin(), fast::count<N>(), M(), sqr_add()));
}
#endif
***************
*** 809,815 ****
if (scal != T(0)) {
T a_scl = a_in / scal;
T b_scl = b_in / scal;
! r = scal * sqrt(a_scl * a_scl + b_scl * b_scl);
if (roe < T(0)) r *= -1;
c_ = a_in / r;
s_ = b_in / r;
--- 807,813 ----
if (scal != T(0)) {
T a_scl = a_in / scal;
T b_scl = b_in / scal;
! r = scal * std::sqrt(a_scl * a_scl + b_scl * b_scl);
if (roe < T(0)) r *= -1;
c_ = a_in / r;
s_ = b_in / r;
***************
*** 842,855 ****
if (abs_a > abs_b) {
// 1/cs = sqrt( 1 + |b|^2 / |a|^2 )
T t = abs_b / abs_a;
! T tt = sqrt(T(1) + t * t);
c_ = T(1) / tt;
s_ = t * c_;
r_ = a * tt;
} else {
// 1/sn = sign(a) * sqrt( 1 + |a|^2/|b|^2 )
T t = abs_a / abs_b;
! T tt = sqrt(T(1) + t * t);
s_ = sign(a) / tt;
c_ = t * s_;
r_ = b * tt;
--- 840,853 ----
if (abs_a > abs_b) {
// 1/cs = sqrt( 1 + |b|^2 / |a|^2 )
T t = abs_b / abs_a;
! T tt = std::sqrt(T(1) + t * t);
c_ = T(1) / tt;
s_ = t * c_;
r_ = a * tt;
} else {
// 1/sn = sign(a) * sqrt( 1 + |a|^2/|b|^2 )
T t = abs_a / abs_b;
! T tt = std::sqrt(T(1) + t * t);
s_ = sign(a) / tt;
c_ = t * s_;
r_ = b * tt;
***************
*** 963,980 ****
g2 = abs_sq(gs);
fs = f / f1;
f2 = abs_sq(fs);
! d = sqrt(T(1) + g2 / f2);
cs = T(1) / d;
sn = MTL_CONJ(gs) * fs * (cs / f2);
r_ = f * d;
} else {
fs = f / g1;
f2 = abs_sq(fs);
! fa = sqrt(f2);
gs = g / g1;
g2 = abs_sq(gs);
! ga = sqrt(g2);
! d = sqrt(T(1) + f2 / g2);
di = T(1) / d;
cs = (fa / ga ) * di;
ss = (MTL_CONJ(gs) * fs) / (fa * ga);
--- 961,978 ----
g2 = abs_sq(gs);
fs = f / f1;
f2 = abs_sq(fs);
! d = std::sqrt(T(1) + g2 / f2);
cs = T(1) / d;
sn = MTL_CONJ(gs) * fs * (cs / f2);
r_ = f * d;
} else {
fs = f / g1;
f2 = abs_sq(fs);
! fa = std::sqrt(f2);
gs = g / g1;
g2 = abs_sq(gs);
! ga = std::sqrt(g2);
! d = std::sqrt(T(1) + f2 / g2);
di = T(1) / d;
cs = (fa / ga ) * di;
ss = (MTL_CONJ(gs) * fs) / (fa * ga);
***************
*** 1080,1097 ****
g2 = abs_sq(gs);
fs = f / f1;
f2 = abs_sq(fs);
! d = sqrt(T(1) + g2 / f2);
cs = T(1) / d;
sn = MTL_CONJ(gs) * fs * (cs / f2);
r_ = f * d;
} else {
fs = f / g1;
f2 = abs_sq(fs);
! fa = sqrt(f2);
gs = g / g1;
g2 = abs_sq(gs);
! ga = sqrt(g2);
! d = sqrt(T(1) + f2 / g2);
di = T(1) / d;
cs = (fa / ga ) * di;
ss = (MTL_CONJ(gs) * fs) / (fa * ga);
--- 1078,1095 ----
g2 = abs_sq(gs);
fs = f / f1;
f2 = abs_sq(fs);
! d = std::sqrt(T(1) + g2 / f2);
cs = T(1) / d;
sn = MTL_CONJ(gs) * fs * (cs / f2);
r_ = f * d;
} else {
fs = f / g1;
f2 = abs_sq(fs);
! fa = std::sqrt(f2);
gs = g / g1;
g2 = abs_sq(gs);
! ga = std::sqrt(g2);
! d = std::sqrt(T(1) + f2 / g2);
di = T(1) / d;
cs = (fa / ga ) * di;
ss = (MTL_CONJ(gs) * fs) / (fa * ga);
***************
*** 1190,1207 ****
g2 = abs_sq(gs);
fs = f / f1;
f2 = abs_sq(fs);
! d = sqrt(T(1) + g2 / f2);
cs = T(1) / d;
sn = MTL_CONJ(gs) * fs * (cs / f2);
r_ = f * d;
} else {
fs = f / g1;
f2 = abs_sq(fs);
! fa = sqrt(f2);
gs = g / g1;
g2 = abs_sq(gs);
! ga = sqrt(g2);
! d = sqrt(T(1) + f2 / g2);
di = T(1) / d;
cs = (fa / ga ) * di;
ss = (MTL_CONJ(gs) * fs) / (fa * ga);
--- 1188,1205 ----
g2 = abs_sq(gs);
fs = f / f1;
f2 = abs_sq(fs);
! d = std::sqrt(T(1) + g2 / f2);
cs = T(1) / d;
sn = MTL_CONJ(gs) * fs * (cs / f2);
r_ = f * d;
} else {
fs = f / g1;
f2 = abs_sq(fs);
! fa = std::sqrt(f2);
gs = g / g1;
g2 = abs_sq(gs);
! ga = std::sqrt(g2);
! d = std::sqrt(T(1) + f2 / g2);
di = T(1) / d;
cs = (fa / ga ) * di;
ss = (MTL_CONJ(gs) * fs) / (fa * ga);
***************
*** 1267,1273 ****
template <class T>
inline T two_norm3(const T& x, const T& y, const T& z) {
! return sqrt(x*x + y*y + z*z);
}
//: Generate Householder Transform
--- 1265,1271 ----
template <class T>
inline T two_norm3(const T& x, const T& y, const T& z) {
! return std::sqrt(x*x + y*y + z*z);
}
//: Generate Householder Transform
diff -c3 -r mtl-2.1.2-22.orig/mtl/rect_indexer.h mtl-2.1.2-22/mtl/rect_indexer.h
*** mtl-2.1.2-22.orig/mtl/rect_indexer.h Tue Jul 5 08:11:49 2005
--- mtl-2.1.2-22/mtl/rect_indexer.h Thu Aug 18 05:18:28 2005
***************
*** 82,92 ****
inline rect_indexer(const Indexer& x) : dim(x.dim) { }
#endif
- #if (defined __SUNPRO_CC)
- template <class S, int MMM, int NNN>
- inline rect_indexer(const dimension<S,MMM,NNN>& x) : dim(x) { }
- #endif
-
inline rect_indexer(const strided_type& x, strideable)
: dim(x.dim.transpose()) { }
--- 82,87 ----
diff -c3 -r mtl-2.1.2-22.orig/mtl/utils.h mtl-2.1.2-22/mtl/utils.h
*** mtl-2.1.2-22.orig/mtl/utils.h Tue Jul 5 08:11:49 2005
--- mtl-2.1.2-22/mtl/utils.h Thu Aug 18 05:18:28 2005
***************
*** 459,472 ****
inline float
make_rand_element(float)
{
! float r = float(rand());
return r/float(RAND_MAX)*10.0;
}
inline double
make_rand_element(double)
{
! double r = double(rand());
return r/double(RAND_MAX)*10.0L;
}
--- 459,472 ----
inline float
make_rand_element(float)
{
! float r = float(std::rand());
return r/float(RAND_MAX)*10.0;
}
inline double
make_rand_element(double)
{
! double r = double(std::rand());
return r/double(RAND_MAX)*10.0L;
}