static void invoke( char const jobz, char const range, MatrixA& a, real_type const vl, real_type const vu, integer_t const il, integer_t const iu, real_type const abstol, integer_t& m, VectorW& w, MatrixZ& z, VectorIFAIL& ifail, integer_t& info, detail::workspace3< WORK, RWORK, IWORK > work ) { BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixA >::value_type, typename traits::matrix_traits< MatrixZ >::value_type >::value) ); BOOST_ASSERT( jobz == 'N' || jobz == 'V' ); BOOST_ASSERT( range == 'A' || range == 'V' || range == 'I' ); BOOST_ASSERT( traits::matrix_uplo_tag(a) == 'U' || traits::matrix_uplo_tag(a) == 'L' ); BOOST_ASSERT( traits::matrix_num_columns(a) >= 0 ); BOOST_ASSERT( traits::leading_dimension(a) >= std::max(1, traits::matrix_num_columns(a)) ); BOOST_ASSERT( traits::vector_size(w) >= traits::matrix_num_columns(a) ); BOOST_ASSERT( traits::vector_size(work.select(value_type())) >= min_size_work( traits::matrix_num_columns(a) )); BOOST_ASSERT( traits::vector_size(work.select(real_type())) >= min_size_rwork( traits::matrix_num_columns(a) )); BOOST_ASSERT( traits::vector_size(work.select(integer_t())) >= min_size_iwork( traits::matrix_num_columns(a) )); detail::heevx( jobz, range, traits::matrix_uplo_tag(a), traits::matrix_num_columns(a), traits::matrix_storage(a), traits::leading_dimension(a), vl, vu, il, iu, abstol, m, traits::vector_storage(w), traits::matrix_storage(z), traits::leading_dimension(z), traits::vector_storage(work.select(value_type())), traits::vector_size(work.select(value_type())), traits::vector_storage(work.select(real_type())), traits::vector_storage(work.select(integer_t())), traits::vector_storage(ifail), info ); }
static void invoke( integer_t const itype, char const jobz, integer_t const n, MatrixA& a, MatrixB& b, VectorW& w, integer_t& info, detail::workspace3< WORK, RWORK, IWORK > work ) { BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixA >::value_type, typename traits::matrix_traits< MatrixB >::value_type >::value) ); BOOST_ASSERT( jobz == 'N' || jobz == 'V' ); BOOST_ASSERT( traits::matrix_uplo_tag(a) == 'U' || traits::matrix_uplo_tag(a) == 'L' ); BOOST_ASSERT( n >= 0 ); BOOST_ASSERT( traits::leading_dimension(a) >= std::max(1,n) ); BOOST_ASSERT( traits::leading_dimension(b) >= std::max(1,n) ); BOOST_ASSERT( traits::vector_size(work.select(value_type())) >= min_size_work( jobz, n )); BOOST_ASSERT( traits::vector_size(work.select(real_type())) >= min_size_rwork( jobz, n )); BOOST_ASSERT( traits::vector_size(work.select(integer_t())) >= min_size_iwork( jobz, n )); detail::hegvd( itype, jobz, traits::matrix_uplo_tag(a), n, traits::matrix_storage(a), traits::leading_dimension(a), traits::matrix_storage(b), traits::leading_dimension(b), traits::vector_storage(w), traits::vector_storage(work.select(value_type())), traits::vector_size(work.select(value_type())), traits::vector_storage(work.select(real_type())), traits::vector_size(work.select(real_type())), traits::vector_storage(work.select(integer_t())), traits::vector_size(work.select(integer_t())), info ); }
static void invoke( char const range, char const order, integer_t const n, real_type const vl, real_type const vu, integer_t const il, integer_t const iu, real_type const abstol, VectorD& d, VectorE& e, integer_t& m, integer_t& nsplit, VectorW& w, VectorIBLOCK& iblock, VectorISPLIT& isplit, integer_t& info, detail::workspace2< WORK, IWORK > work ) { BOOST_STATIC_ASSERT( (boost::is_same< typename traits::vector_traits< VectorD >::value_type, typename traits::vector_traits< VectorE >::value_type >::value) ); BOOST_STATIC_ASSERT( (boost::is_same< typename traits::vector_traits< VectorD >::value_type, typename traits::vector_traits< VectorW >::value_type >::value) ); BOOST_STATIC_ASSERT( (boost::is_same< typename traits::vector_traits< VectorIBLOCK >::value_type, typename traits::vector_traits< VectorISPLIT >::value_type >::value) ); BOOST_ASSERT( range == 'A' || range == 'V' || range == 'I' ); BOOST_ASSERT( order == 'B' || order == 'E' ); BOOST_ASSERT( n >= 0 ); BOOST_ASSERT( traits::vector_size(d) >= n ); BOOST_ASSERT( traits::vector_size(e) >= n-1 ); BOOST_ASSERT( traits::vector_size(w) >= n ); BOOST_ASSERT( traits::vector_size(isplit) >= n ); BOOST_ASSERT( traits::vector_size(work.select(real_type())) >= min_size_work( n )); BOOST_ASSERT( traits::vector_size(work.select(integer_t())) >= min_size_iwork( n )); detail::stebz( range, order, n, vl, vu, il, iu, abstol, traits::vector_storage(d), traits::vector_storage(e), m, nsplit, traits::vector_storage(w), traits::vector_storage(iblock), traits::vector_storage(isplit), traits::vector_storage(work.select(real_type())), traits::vector_storage(work.select(integer_t())), info ); }
static void invoke( char const fact, MatrixA& a, MatrixAF& af, char& equed, VectorS& s, MatrixB& b, MatrixX& x, real_type& rcond, VectorFERR& ferr, VectorBERR& berr, integer_t& info, detail::workspace2< WORK, IWORK > work ) { BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixA >::value_type, typename traits::matrix_traits< MatrixAF >::value_type >::value) ); BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixA >::value_type, typename traits::vector_traits< VectorS >::value_type >::value) ); BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixA >::value_type, typename traits::matrix_traits< MatrixB >::value_type >::value) ); BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixA >::value_type, typename traits::matrix_traits< MatrixX >::value_type >::value) ); BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixA >::value_type, typename traits::vector_traits< VectorFERR >::value_type >::value) ); BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixA >::value_type, typename traits::vector_traits< VectorBERR >::value_type >::value) ); BOOST_ASSERT( fact == 'F' || fact == 'Y' || fact == 'N' || fact == 'E' ); BOOST_ASSERT( traits::matrix_uplo_tag(a) == 'U' || traits::matrix_uplo_tag(a) == 'L' ); BOOST_ASSERT( traits::matrix_num_columns(a) >= 0 ); BOOST_ASSERT( traits::matrix_num_columns(x) >= 0 ); BOOST_ASSERT( traits::leading_dimension(a) >= std::max(1, traits::matrix_num_columns(a)) ); BOOST_ASSERT( traits::leading_dimension(af) >= std::max(1, traits::matrix_num_columns(a)) ); BOOST_ASSERT( equed == 'N' || equed == 'Y' ); BOOST_ASSERT( traits::leading_dimension(b) >= std::max(1, traits::matrix_num_columns(a)) ); BOOST_ASSERT( traits::leading_dimension(x) >= std::max(1, traits::matrix_num_columns(a)) ); BOOST_ASSERT( traits::vector_size(berr) >= traits::matrix_num_columns(x) ); BOOST_ASSERT( traits::vector_size(work.select(real_type())) >= min_size_work( traits::matrix_num_columns(a) )); BOOST_ASSERT( traits::vector_size(work.select(integer_t())) >= min_size_iwork( traits::matrix_num_columns(a) )); detail::posvx( fact, traits::matrix_uplo_tag(a), traits::matrix_num_columns(a), traits::matrix_num_columns(x), traits::matrix_storage(a), traits::leading_dimension(a), traits::matrix_storage(af), traits::leading_dimension(af), equed, traits::vector_storage(s), traits::matrix_storage(b), traits::leading_dimension(b), traits::matrix_storage(x), traits::leading_dimension(x), rcond, traits::vector_storage(ferr), traits::vector_storage(berr), traits::vector_storage(work.select(real_type())), traits::vector_storage(work.select(integer_t())), info ); }
void GGLAssembler::expand(integer_t& d, const component_t& s, int dbits) { if (s.l || (s.flags & CLEAR_HI)) { extract(d, s.reg, s.h, s.l, 32); expand(d, d, dbits); } else { expand(d, integer_t(s.reg, s.size(), s.flags), dbits); } }
static void invoke( integer_t const n, MatrixAP& ap, MatrixAFP& afp, VectorIPIV& ipiv, MatrixB& b, MatrixX& x, VectorFERR& ferr, VectorBERR& berr, integer_t& info, detail::workspace2< WORK, IWORK > work ) { BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixAP >::value_type, typename traits::matrix_traits< MatrixAFP >::value_type >::value) ); BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixAP >::value_type, typename traits::matrix_traits< MatrixB >::value_type >::value) ); BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixAP >::value_type, typename traits::matrix_traits< MatrixX >::value_type >::value) ); BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixAP >::value_type, typename traits::vector_traits< VectorFERR >::value_type >::value) ); BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixAP >::value_type, typename traits::vector_traits< VectorBERR >::value_type >::value) ); BOOST_ASSERT( traits::matrix_uplo_tag(a) == 'U' || traits::matrix_uplo_tag(a) == 'L' ); BOOST_ASSERT( n >= 0 ); BOOST_ASSERT( traits::matrix_num_columns(x) >= 0 ); BOOST_ASSERT( traits::vector_size(afp) >= n*(n+1)/2 ); BOOST_ASSERT( traits::vector_size(ipiv) >= n ); BOOST_ASSERT( traits::leading_dimension(b) >= std::max(1,n) ); BOOST_ASSERT( traits::leading_dimension(x) >= std::max(1,n) ); BOOST_ASSERT( traits::vector_size(berr) >= traits::matrix_num_columns(x) ); BOOST_ASSERT( traits::vector_size(work.select(real_type())) >= min_size_work( n )); BOOST_ASSERT( traits::vector_size(work.select(integer_t())) >= min_size_iwork( n )); detail::sprfs( traits::matrix_uplo_tag(a), n, traits::matrix_num_columns(x), traits::matrix_storage(ap), traits::matrix_storage(afp), traits::vector_storage(ipiv), traits::matrix_storage(b), traits::leading_dimension(b), traits::matrix_storage(x), traits::leading_dimension(x), traits::vector_storage(ferr), traits::vector_storage(berr), traits::vector_storage(work.select(real_type())), traits::vector_storage(work.select(integer_t())), info ); }
static void invoke( char const jobz, char const range, integer_t const n, integer_t const ka, integer_t const kb, MatrixAB& ab, MatrixBB& bb, MatrixQ& q, real_type const vl, real_type const vu, integer_t const il, integer_t const iu, real_type const abstol, integer_t& m, VectorW& w, MatrixZ& z, VectorIFAIL& ifail, integer_t& info, detail::workspace2< WORK, IWORK > work ) { BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixAB >::value_type, typename traits::matrix_traits< MatrixBB >::value_type >::value) ); BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixAB >::value_type, typename traits::matrix_traits< MatrixQ >::value_type >::value) ); BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixAB >::value_type, typename traits::vector_traits< VectorW >::value_type >::value) ); BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixAB >::value_type, typename traits::matrix_traits< MatrixZ >::value_type >::value) ); BOOST_ASSERT( jobz == 'N' || jobz == 'V' ); BOOST_ASSERT( range == 'A' || range == 'V' || range == 'I' ); BOOST_ASSERT( traits::matrix_uplo_tag(ab) == 'U' || traits::matrix_uplo_tag(ab) == 'L' ); BOOST_ASSERT( n >= 0 ); BOOST_ASSERT( ka >= 0 ); BOOST_ASSERT( kb >= 0 ); BOOST_ASSERT( traits::leading_dimension(ab) >= ka+1 ); BOOST_ASSERT( traits::leading_dimension(bb) >= kb+1 ); BOOST_ASSERT( traits::vector_size(work.select(real_type())) >= min_size_work( n )); BOOST_ASSERT( traits::vector_size(work.select(integer_t())) >= min_size_iwork( n )); detail::sbgvx( jobz, range, traits::matrix_uplo_tag(ab), n, ka, kb, traits::matrix_storage(ab), traits::leading_dimension(ab), traits::matrix_storage(bb), traits::leading_dimension(bb), traits::matrix_storage(q), traits::leading_dimension(q), vl, vu, il, iu, abstol, m, traits::vector_storage(w), traits::matrix_storage(z), traits::leading_dimension(z), traits::vector_storage(work.select(real_type())), traits::vector_storage(work.select(integer_t())), traits::vector_storage(ifail), info ); }
RString SetThreadPrecedence( float prec ) { // Real values are between 0 and 63. DEBUG_ASSERT( 0.0f <= prec && prec <= 1.0f ); thread_precedence_policy po = { integer_t( lrintf(prec * 63) ) }; kern_return_t ret = thread_policy_set( mach_thread_self(), THREAD_PRECEDENCE_POLICY, (thread_policy_t)&po, THREAD_PRECEDENCE_POLICY_COUNT ); if( ret != KERN_SUCCESS ) return mach_error_string( ret ); return RString(); }
static void invoke( char const jobz, MatrixA& a, VectorW& w, integer_t& info, detail::workspace2< WORK, IWORK > work ) { BOOST_STATIC_ASSERT( (boost::is_same< typename traits::matrix_traits< MatrixA >::value_type, typename traits::vector_traits< VectorW >::value_type >::value) ); BOOST_ASSERT( jobz == 'N' || jobz == 'V' ); BOOST_ASSERT( traits::matrix_uplo_tag(a) == 'U' || traits::matrix_uplo_tag(a) == 'L' ); BOOST_ASSERT( traits::matrix_num_columns(a) >= 0 ); BOOST_ASSERT( traits::leading_dimension(a) >= std::max(1, traits::matrix_num_columns(a)) ); BOOST_ASSERT( traits::vector_size(work.select(real_type())) >= min_size_work( jobz, traits::matrix_num_columns(a) )); BOOST_ASSERT( traits::vector_size(work.select(integer_t())) >= min_size_iwork( jobz, traits::matrix_num_columns(a) )); detail::syevd( jobz, traits::matrix_uplo_tag(a), traits::matrix_num_columns(a), traits::matrix_storage(a), traits::leading_dimension(a), traits::vector_storage(w), traits::vector_storage(work.select(real_type())), traits::vector_size(work.select(real_type())), traits::vector_storage(work.select(integer_t())), traits::vector_size(work.select(integer_t())), info ); }
static void invoke( char const compz, integer_t const n, VectorD& d, VectorE& e, MatrixZ& z, integer_t& info, detail::workspace2< WORK, IWORK > work ) { BOOST_STATIC_ASSERT( (boost::is_same< typename traits::vector_traits< VectorD >::value_type, typename traits::vector_traits< VectorE >::value_type >::value) ); BOOST_STATIC_ASSERT( (boost::is_same< typename traits::vector_traits< VectorD >::value_type, typename traits::matrix_traits< MatrixZ >::value_type >::value) ); BOOST_ASSERT( compz == 'N' || compz == 'I' || compz == 'V' ); BOOST_ASSERT( n >= 0 ); BOOST_ASSERT( traits::vector_size(e) >= n-1 ); BOOST_ASSERT( traits::vector_size(work.select(real_type())) >= min_size_work( $CALL_MIN_SIZE )); BOOST_ASSERT( traits::vector_size(work.select(integer_t())) >= min_size_iwork( compz, n )); detail::stedc( compz, n, traits::vector_storage(d), traits::vector_storage(e), traits::matrix_storage(z), traits::leading_dimension(z), traits::vector_storage(work.select(real_type())), traits::vector_size(work.select(real_type())), traits::vector_storage(work.select(integer_t())), traits::vector_size(work.select(integer_t())), info ); }
number_t* calculator::calculate( const std::string& expression, const bool debug) { std::stringstream postfix(expression); std::string s; try { while ( postfix >> s ) { number_t* n = stringToNumber(s); if( n != nullptr ) stack_ << n; else { number_t* el1 = nullptr; number_t* el2 = nullptr; stack_ >> el2; /* Right */ stack_ >> el1; /* Left */ if (debug) { std::cout << "( "; el1->who(); std::cout << " : "; el1->toStream(); std::cout << " ) " << s[0] << " ( "; el2->who(); std::cout << " : "; el2->toStream(); std::cout << " )" << std::endl; } try { switch( s[0] ) { case '+': stack_ << (*el1 + *el2); break; case '-': stack_ << (*el1 - *el2); break; case '*': stack_ << (*el1 * *el2); break; case '/': stack_ << (*el1 / *el2); break; default: throw badSyntaxException(s); } } catch (const zeroDivisionException &e) { std::string response; std::cout << e.what() << "\nDivide by 1 ? [y/n]: "; std::getline(std::cin, response); if (response.size()==1 && (response[0] == 'y' || response[0] == 'Y')) stack_ << (*el1 / integer_t(1)); else return nullptr; } if (el1 != nullptr) delete el1; if (el2 != nullptr) delete el2; } } if (stack_.size() > 1) throw notEmptyStack(); return stack_.pop(); } catch (const badPos &e) { std::cerr << "Internal stack_ error: " << e.what() << std::endl; } catch (const emptyStack &e) { std::cerr << "Syntax error (" << e.what() << ")" << std::endl; } catch (const notEmptyStack &e) { std::cerr << e.what() << std::endl; while (stack_.size() > 1) delete stack_.pop(); } catch (const std::exception &e) { std::cerr << e.what() << std::endl; } return nullptr; }