OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/gnu-stable/gcc-4.5.1/libstdc++-v3/testsuite/26_numerics/complex
    from Rev 816 to Rev 826
    Reverse comparison

Rev 816 → Rev 826

/13450.cc
0,0 → 1,82
// { dg-do run { xfail broken_cplxf_arg } }
 
// Copyright (C) 2004, 2009 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
 
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
 
// 26.2.8 complex transcendentals
 
#include <complex>
#include <limits>
#include <testsuite_hooks.h>
 
template<typename T>
void test01_do(T a, T b)
{
using namespace std;
bool test __attribute__((unused)) = true;
typedef complex<T> cplx;
 
T eps = numeric_limits<T>::epsilon() * 100;
cplx ref = pow(cplx(a, T()), cplx(b, T()));
cplx res1 = pow(a, cplx(b, T()));
cplx res2 = pow(cplx(a, T()), b);
VERIFY( abs(ref - res1) < eps );
VERIFY( abs(ref - res2) < eps );
VERIFY( abs(res1 - res2) < eps );
}
 
// libstdc++/13450
void test01()
{
float f1 = -1.0f;
float f2 = 0.5f;
test01_do(f1, f2);
 
f1 = -3.2f;
f2 = 1.4f;
test01_do(f1, f2);
 
double d1 = -1.0;
double d2 = 0.5;
test01_do(d1, d2);
 
d1 = -3.2;
d2 = 1.4;
test01_do(d1, d2);
 
#if __LDBL_MANT_DIG__ != 106
/* For IBM long double, epsilon is too small (since 1.0 plus any
double is representable) to be able to expect results within
epsilon * 100 (which may be much less than 1ulp for a particular
long double value). */
long double ld1 = -1.0l;
long double ld2 = 0.5l;
test01_do(ld1, ld2);
 
ld1 = -3.2l;
ld2 = 1.4l;
test01_do(ld1, ld2);
#endif
}
 
int main()
{
test01();
return 0;
}
/complex_value.cc
0,0 → 1,65
// { dg-do run { xfail broken_cplxf_arg } }
// { dg-options "-O0" }
// 2000-11-20
// Benjamin Kosnik bkoz@redhat.com
 
// Copyright (C) 2000, 2003, 2004, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
 
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
 
#include <complex>
#include <testsuite_hooks.h>
 
void test01()
{
using namespace std;
bool test __attribute__((unused)) = true;
typedef complex<double> complex_type;
const double cd1 = -11.451;
const double cd2 = -442.1533;
 
complex_type a(cd1, cd2);
double d;
d = a.real();
VERIFY( d == cd1);
 
d = a.imag();
VERIFY(d == cd2);
 
complex_type c(cd1, cd2);
double d6 = abs(c);
VERIFY( d6 >= 0);
 
double d7 = arg(c);
double d8 = atan2(c.imag(), c.real());
VERIFY( d7 == d8);
 
double d9 = norm(c);
double d10 = d6 * d6;
VERIFY(d9 - d10 == 0);
 
complex_type e = conj(c);
complex_type f = polar(c.imag(), 0.0);
VERIFY(f.real() != 0);
}
 
 
int main()
{
test01();
return 0;
}
/buggy_complex.cc
0,0 → 1,35
// 2000-02-09
// Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
 
// Copyright (C) 1999, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
 
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
 
 
// Test buggy builtin GNU __complex__ support. This used to cause
// an ICE on some 64-bits plateforms.
// Origin: petter@matfys.lth.se
 
#include <complex>
 
int main()
{
std::complex<double> a(9), b(0, 8), c;
 
c = a * b;
 
return 0;
}
/dr844.cc
0,0 → 1,51
// { dg-options "-std=gnu++0x" }
// 2008-06-12 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
 
#include <complex>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
 
// DR 844. complex pow return type is ambiguous.
void test01()
{
bool test __attribute__((unused)) = true;
using __gnu_test::check_ret_type;
 
typedef std::complex<float> cmplx_f_type;
typedef std::complex<double> cmplx_d_type;
typedef std::complex<long double> cmplx_ld_type;
 
const int i1 = 1;
const float f1 = 1.0f;
const double d1 = 1.0;
const long double ld1 = 1.0l;
 
check_ret_type<cmplx_d_type>(std::pow(cmplx_f_type(f1, f1), i1));
VERIFY( std::pow(cmplx_f_type(f1, f1), i1)
== std::pow(cmplx_d_type(f1, f1), double(i1)) );
check_ret_type<cmplx_d_type>(std::pow(cmplx_d_type(d1, d1), i1));
check_ret_type<cmplx_ld_type>(std::pow(cmplx_ld_type(ld1, ld1), i1));
}
 
int main()
{
test01();
return 0;
}
/pow.cc
0,0 → 1,16
// { dg-do run { xfail broken_cplxf_arg } }
// PR libstdc++/10689
// Origin: Daniel.Levine@jhuaph.edu
// { dg-add-options ieee }
 
#include <complex>
#include <testsuite_hooks.h>
 
int main()
{
std::complex<double> z;
 
VERIFY( pow(z, 1.0/3.0) == 0.0 );
 
return 0;
}
/dr781_dr1137.cc
0,0 → 1,70
// { dg-options "-std=gnu++0x" }
// 2008-05-22 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
 
#include <complex>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
 
// DR 781. std::complex should add missing C99 functions.
// DR 1137. Return type of conj and proj.
void test01()
{
bool test __attribute__((unused)) = true;
using __gnu_test::check_ret_type;
 
typedef std::complex<float> cmplx_f_type;
typedef std::complex<double> cmplx_d_type;
typedef std::complex<long double> cmplx_ld_type;
 
const int i1 = 1;
const float f1 = 1.0f;
const double d1 = 1.0;
const long double ld1 = 1.0l;
 
const cmplx_f_type c_f1(f1, f1);
const cmplx_d_type c_d1(d1, d1);
const cmplx_ld_type c_ld1(ld1, ld1);
 
check_ret_type<cmplx_f_type>(std::proj(c_f1));
check_ret_type<cmplx_d_type>(std::proj(c_d1));
check_ret_type<cmplx_ld_type>(std::proj(c_ld1));
 
check_ret_type<float>(std::proj(f1));
check_ret_type<double>(std::proj(d1));
check_ret_type<double>(std::proj(i1));
VERIFY( std::proj(i1) == std::proj(double(i1)) );
check_ret_type<long double>(std::proj(ld1));
 
check_ret_type<cmplx_f_type>(std::conj(c_f1));
check_ret_type<cmplx_d_type>(std::conj(c_d1));
check_ret_type<cmplx_ld_type>(std::conj(c_ld1));
 
check_ret_type<float>(std::conj(f1));
check_ret_type<double>(std::conj(d1));
check_ret_type<double>(std::conj(i1));
VERIFY( std::conj(i1) == std::conj(double(i1)) );
check_ret_type<long double>(std::conj(ld1));
}
 
int main()
{
test01();
return 0;
}
/dr387.cc
0,0 → 1,51
// 2008-05-22 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
 
#include <complex>
#include <testsuite_hooks.h>
 
// DR 387. std::complex over-encapsulated.
template<typename T>
void
do_test()
{
bool test __attribute__((unused)) = true;
 
const T r = 1.0;
const T i = -1.0;
const T v = 0.0;
 
std::complex<T> z1(r, i);
z1.real(v);
VERIFY( z1.real() == v );
VERIFY( z1.imag() == i );
 
std::complex<T> z2(r, i);
z2.imag(v);
VERIFY( z2.real() == r );
VERIFY( z2.imag() == v );
}
 
int main()
{
do_test<float>();
do_test<double>();
do_test<long double>();
return 0;
}
/dr387_2.cc
0,0 → 1,30
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
//
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
 
#include <complex>
 
// DR 387. std::complex over-encapsulated.
// http://gcc.gnu.org/ml/gcc/2009-03/msg00264.html
typedef std::complex<double> C;
 
C f1(C& c) { return c+1.0; }
C f2(C& c) { return c-1.0; }
C f3(C& c) { return 1.0+c; }
C f4(C& c) { return 1.0-c; }
/inserters_extractors/wchar_t/1.cc
0,0 → 1,136
// Copyright (C) 2007, 2009 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
 
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
 
 
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <testsuite_hooks.h>
#include <cmath>
 
template<typename R>
inline bool flteq(R x, R y)
{
if (x == R(0)) return y == R(0);
else return std::fabs(x-y) < 1e-6*std::fabs(x);
}
 
template<typename R>
int
test_good(std::wstring str, R x, R y)
{
bool test __attribute__((unused)) = true;
std::complex<R> z;
wchar_t ch;
std::wistringstream iss(str);
iss >> z >> ch;
VERIFY( iss.good() );
VERIFY( flteq(z.real(), x) );
VERIFY( flteq(z.imag(), y) );
VERIFY( ch == L'#' );
return 0;
}
 
template<typename R>
int
test_fail(std::wstring str)
{
bool test __attribute__((unused)) = true;
std::complex<R> z;
std::wistringstream iss(str);
iss >> z;
VERIFY( iss.fail() && !iss.bad() );
return 0;
}
 
template<typename R>
int
testall()
{
test_good<R>(L"(-1.1,3.7)#", -1.1, 3.7);
test_good<R>(L"( .7e6 , \n-3.1)#", .7e6, -3.1);
test_good<R>(L"(\t0,-1)#", 0.0, -1.0);
test_good<R>(L"(-3.14)#", -3.14, 0.0);
test_good<R>(L"-.1#", -.1, 0.0);
test_good<R>(L" ( -2.7e3 )#", -2.7e3, 0.0);
test_good<R>(L" -.1#", -.1, 0.0);
test_fail<R>(L"(a,1)");
test_fail<R>(L"(,1)");
test_fail<R>(L"(1,a)");
test_fail<R>(L"(1, )");
test_fail<R>(L"|1,1)");
test_fail<R>(L"(1|1)");
test_fail<R>(L"(1,1|");
return 0;
}
 
// libstdc++/2970
void test01()
{
using namespace std;
bool test __attribute__((unused)) = true;
complex<float> cf01(-1.1, -333.2);
wstringstream ss;
ss << cf01;
wstring str = ss.str();
VERIFY( str == L"(-1.1,-333.2)" );
}
 
// libstdc++/2985
struct gnu_char_traits : public std::char_traits<wchar_t>
{ };
 
typedef std::basic_ostringstream<wchar_t, gnu_char_traits> gnu_sstream;
template class std::basic_string<wchar_t, gnu_char_traits,
std::allocator<wchar_t> >;
 
void test02()
{
bool test __attribute__((unused)) = true;
 
// Construct locale with specialized facets.
typedef gnu_sstream::__num_put_type numput_type;
typedef gnu_sstream::__num_get_type numget_type;
std::locale loc_c = std::locale::classic();
std::locale loc_1(loc_c, new numput_type);
std::locale loc_2(loc_1, new numget_type);
VERIFY( std::has_facet<numput_type>(loc_2) );
VERIFY( std::has_facet<numget_type>(loc_2) );
 
gnu_sstream sstr;
sstr.imbue(loc_2);
 
 
std::complex<double> x(3, 4);
sstr << x;
VERIFY( sstr.str() == L"(3,4)" );
}
 
int
main()
{
testall<float>();
testall<double>();
testall<long double>();
 
test01();
test02();
 
return 0;
}
/inserters_extractors/char/1.cc
0,0 → 1,138
// 2000-02-10
// Petter Urkedal <petter@matfys.lth.se>
 
// Copyright (C) 2000, 2003, 2009 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
 
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
 
 
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <testsuite_hooks.h>
#include <cmath>
 
template<typename R>
inline bool flteq(R x, R y)
{
if (x == R(0)) return y == R(0);
else return std::fabs(x-y) < 1e-6*std::fabs(x);
}
 
template<typename R>
int
test_good(std::string str, R x, R y)
{
bool test __attribute__((unused)) = true;
std::complex<R> z;
char ch;
std::istringstream iss(str);
iss >> z >> ch;
VERIFY( iss.good() );
VERIFY( flteq(z.real(), x) );
VERIFY( flteq(z.imag(), y) );
VERIFY( ch == '#' );
return 0;
}
 
template<typename R>
int
test_fail(std::string str)
{
bool test __attribute__((unused)) = true;
std::complex<R> z;
std::istringstream iss(str);
iss >> z;
VERIFY( iss.fail() && !iss.bad() );
return 0;
}
 
template<typename R>
int
testall()
{
test_good<R>("(-1.1,3.7)#", -1.1, 3.7);
test_good<R>("( .7e6 , \n-3.1)#", .7e6, -3.1);
test_good<R>("(\t0,-1)#", 0.0, -1.0);
test_good<R>("(-3.14)#", -3.14, 0.0);
test_good<R>("-.1#", -.1, 0.0);
test_good<R>(" ( -2.7e3 )#", -2.7e3, 0.0);
test_good<R>(" -.1#", -.1, 0.0);
test_fail<R>("(a,1)");
test_fail<R>("(,1)");
test_fail<R>("(1,a)");
test_fail<R>("(1, )");
test_fail<R>("|1,1)");
test_fail<R>("(1|1)");
test_fail<R>("(1,1|");
return 0;
}
 
// libstdc++/2970
void test01()
{
using namespace std;
bool test __attribute__((unused)) = true;
complex<float> cf01(-1.1, -333.2);
stringstream ss;
ss << cf01;
string str = ss.str();
VERIFY( str == "(-1.1,-333.2)" );
}
 
// libstdc++/2985
struct gnu_char_traits : public std::char_traits<char>
{ };
 
typedef std::basic_ostringstream<char, gnu_char_traits> gnu_sstream;
template class std::basic_string<char, gnu_char_traits, std::allocator<char> >;
 
void test02()
{
bool test __attribute__((unused)) = true;
 
// Construct locale with specialized facets.
typedef gnu_sstream::__num_put_type numput_type;
typedef gnu_sstream::__num_get_type numget_type;
std::locale loc_c = std::locale::classic();
std::locale loc_1(loc_c, new numput_type);
std::locale loc_2(loc_1, new numget_type);
VERIFY( std::has_facet<numput_type>(loc_2) );
VERIFY( std::has_facet<numget_type>(loc_2) );
 
gnu_sstream sstr;
sstr.imbue(loc_2);
 
 
std::complex<double> x(3, 4);
sstr << x;
VERIFY( sstr.str() == "(3,4)" );
}
 
int
main()
{
testall<float>();
testall<double>();
testall<long double>();
 
test01();
test02();
 
return 0;
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.