Initial Commit
This commit is contained in:
@@ -0,0 +1,416 @@
|
||||
#include "MessageClient.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <QUdpSocket>
|
||||
#include <QHostInfo>
|
||||
#include <QTimer>
|
||||
#include <QQueue>
|
||||
#include <QByteArray>
|
||||
#include <QHostAddress>
|
||||
|
||||
#include "NetworkMessage.hpp"
|
||||
|
||||
#include "pimpl_impl.hpp"
|
||||
|
||||
#include "moc_MessageClient.cpp"
|
||||
|
||||
class MessageClient::impl
|
||||
: public QUdpSocket
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
impl (QString const& id, QString const& version, QString const& revision,
|
||||
port_type server_port, MessageClient * self)
|
||||
: self_ {self}
|
||||
, id_ {id}
|
||||
, version_ {version}
|
||||
, revision_ {revision}
|
||||
, server_port_ {server_port}
|
||||
, schema_ {2} // use 2 prior to negotiation not 1 which is broken
|
||||
, heartbeat_timer_ {new QTimer {this}}
|
||||
{
|
||||
connect (heartbeat_timer_, &QTimer::timeout, this, &impl::heartbeat);
|
||||
connect (this, &QIODevice::readyRead, this, &impl::pending_datagrams);
|
||||
|
||||
heartbeat_timer_->start (NetworkMessage::pulse * 1000);
|
||||
|
||||
// bind to an ephemeral port
|
||||
bind ();
|
||||
}
|
||||
|
||||
~impl ()
|
||||
{
|
||||
closedown ();
|
||||
}
|
||||
|
||||
enum StreamStatus {Fail, Short, OK};
|
||||
|
||||
void parse_message (QByteArray const& msg);
|
||||
void pending_datagrams ();
|
||||
void heartbeat ();
|
||||
void closedown ();
|
||||
StreamStatus check_status (QDataStream const&) const;
|
||||
void send_message (QByteArray const&);
|
||||
void send_message (QDataStream const& out, QByteArray const& message)
|
||||
{
|
||||
if (OK == check_status (out))
|
||||
{
|
||||
send_message (message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_EMIT self_->error ("Error creating UDP message");
|
||||
}
|
||||
}
|
||||
|
||||
Q_SLOT void host_info_results (QHostInfo);
|
||||
|
||||
MessageClient * self_;
|
||||
QString id_;
|
||||
QString version_;
|
||||
QString revision_;
|
||||
QString server_string_;
|
||||
port_type server_port_;
|
||||
QHostAddress server_;
|
||||
quint32 schema_;
|
||||
QTimer * heartbeat_timer_;
|
||||
|
||||
// hold messages sent before host lookup completes asynchronously
|
||||
QQueue<QByteArray> pending_messages_;
|
||||
QByteArray last_message_;
|
||||
};
|
||||
|
||||
#include "MessageClient.moc"
|
||||
|
||||
void MessageClient::impl::host_info_results (QHostInfo host_info)
|
||||
{
|
||||
if (QHostInfo::NoError != host_info.error ())
|
||||
{
|
||||
Q_EMIT self_->error ("UDP server lookup failed:\n" + host_info.errorString ());
|
||||
pending_messages_.clear (); // discard
|
||||
}
|
||||
else if (host_info.addresses ().size ())
|
||||
{
|
||||
server_ = host_info.addresses ()[0];
|
||||
|
||||
// send initial heartbeat which allows schema negotiation
|
||||
heartbeat ();
|
||||
|
||||
// clear any backlog
|
||||
while (pending_messages_.size ())
|
||||
{
|
||||
send_message (pending_messages_.dequeue ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessageClient::impl::pending_datagrams ()
|
||||
{
|
||||
while (hasPendingDatagrams ())
|
||||
{
|
||||
QByteArray datagram;
|
||||
datagram.resize (pendingDatagramSize ());
|
||||
QHostAddress sender_address;
|
||||
port_type sender_port;
|
||||
if (0 <= readDatagram (datagram.data (), datagram.size (), &sender_address, &sender_port))
|
||||
{
|
||||
parse_message (datagram);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessageClient::impl::parse_message (QByteArray const& msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
//
|
||||
// message format is described in NetworkMessage.hpp
|
||||
//
|
||||
NetworkMessage::Reader in {msg};
|
||||
if (OK == check_status (in) && id_ == in.id ()) // OK and for us
|
||||
{
|
||||
if (schema_ < in.schema ()) // one time record of server's
|
||||
// negotiated schema
|
||||
{
|
||||
schema_ = in.schema ();
|
||||
}
|
||||
|
||||
//
|
||||
// message format is described in NetworkMessage.hpp
|
||||
//
|
||||
switch (in.type ())
|
||||
{
|
||||
case NetworkMessage::Reply:
|
||||
{
|
||||
// unpack message
|
||||
QTime time;
|
||||
qint32 snr;
|
||||
float delta_time;
|
||||
quint32 delta_frequency;
|
||||
QByteArray mode;
|
||||
QByteArray message;
|
||||
in >> time >> snr >> delta_time >> delta_frequency >> mode >> message;
|
||||
if (check_status (in) != Fail)
|
||||
{
|
||||
Q_EMIT self_->reply (time, snr, delta_time, delta_frequency
|
||||
, QString::fromUtf8 (mode), QString::fromUtf8 (message));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NetworkMessage::Replay:
|
||||
if (check_status (in) != Fail)
|
||||
{
|
||||
last_message_.clear ();
|
||||
Q_EMIT self_->replay ();
|
||||
}
|
||||
break;
|
||||
|
||||
case NetworkMessage::HaltTx:
|
||||
{
|
||||
bool auto_only {false};
|
||||
in >> auto_only;
|
||||
if (check_status (in) != Fail)
|
||||
{
|
||||
Q_EMIT self_->halt_tx (auto_only);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NetworkMessage::FreeText:
|
||||
{
|
||||
QByteArray message;
|
||||
bool send {true};
|
||||
in >> message >> send;
|
||||
if (check_status (in) != Fail)
|
||||
{
|
||||
Q_EMIT self_->free_text (QString::fromUtf8 (message), send);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore
|
||||
//
|
||||
// Note that although server heartbeat messages are not
|
||||
// parsed here they are still partially parsed in the
|
||||
// message reader class to negotiate the maximum schema
|
||||
// number being used on the network.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
Q_EMIT self_->error (QString {"MessageClient exception: %1"}.arg (e.what ()));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
Q_EMIT self_->error ("Unexpected exception in MessageClient");
|
||||
}
|
||||
}
|
||||
|
||||
void MessageClient::impl::heartbeat ()
|
||||
{
|
||||
if (server_port_ && !server_.isNull ())
|
||||
{
|
||||
QByteArray message;
|
||||
NetworkMessage::Builder hb {&message, NetworkMessage::Heartbeat, id_, schema_};
|
||||
hb << NetworkMessage::Builder::schema_number // maximum schema number accepted
|
||||
<< version_.toUtf8 () << revision_.toUtf8 ();
|
||||
if (OK == check_status (hb))
|
||||
{
|
||||
writeDatagram (message, server_, server_port_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessageClient::impl::closedown ()
|
||||
{
|
||||
if (server_port_ && !server_.isNull ())
|
||||
{
|
||||
QByteArray message;
|
||||
NetworkMessage::Builder out {&message, NetworkMessage::Close, id_, schema_};
|
||||
if (OK == check_status (out))
|
||||
{
|
||||
writeDatagram (message, server_, server_port_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessageClient::impl::send_message (QByteArray const& message)
|
||||
{
|
||||
if (server_port_)
|
||||
{
|
||||
if (!server_.isNull ())
|
||||
{
|
||||
if (message != last_message_) // avoid duplicates
|
||||
{
|
||||
writeDatagram (message, server_, server_port_);
|
||||
last_message_ = message;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pending_messages_.enqueue (message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto MessageClient::impl::check_status (QDataStream const& stream) const -> StreamStatus
|
||||
{
|
||||
auto stat = stream.status ();
|
||||
StreamStatus result {Fail};
|
||||
switch (stat)
|
||||
{
|
||||
case QDataStream::ReadPastEnd:
|
||||
result = Short;
|
||||
break;
|
||||
|
||||
case QDataStream::ReadCorruptData:
|
||||
Q_EMIT self_->error ("Message serialization error: read corrupt data");
|
||||
break;
|
||||
|
||||
case QDataStream::WriteFailed:
|
||||
Q_EMIT self_->error ("Message serialization error: write error");
|
||||
break;
|
||||
|
||||
default:
|
||||
result = OK;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
MessageClient::MessageClient (QString const& id, QString const& version, QString const& revision,
|
||||
QString const& server, port_type server_port, QObject * self)
|
||||
: QObject {self}
|
||||
, m_ {id, version, revision, server_port, this}
|
||||
{
|
||||
connect (&*m_, static_cast<void (impl::*) (impl::SocketError)> (&impl::error)
|
||||
, [this] (impl::SocketError e)
|
||||
{
|
||||
#if defined (Q_OS_WIN) && QT_VERSION >= 0x050500
|
||||
if (e != impl::NetworkError // take this out when Qt 5.5
|
||||
// stops doing this
|
||||
// spuriously
|
||||
&& e != impl::ConnectionRefusedError) // not
|
||||
// interested
|
||||
// in this with
|
||||
// UDP socket
|
||||
#else
|
||||
Q_UNUSED (e);
|
||||
#endif
|
||||
{
|
||||
Q_EMIT error (m_->errorString ());
|
||||
}
|
||||
});
|
||||
set_server (server);
|
||||
}
|
||||
|
||||
QHostAddress MessageClient::server_address () const
|
||||
{
|
||||
return m_->server_;
|
||||
}
|
||||
|
||||
auto MessageClient::server_port () const -> port_type
|
||||
{
|
||||
return m_->server_port_;
|
||||
}
|
||||
|
||||
void MessageClient::set_server (QString const& server)
|
||||
{
|
||||
m_->server_.clear ();
|
||||
m_->server_string_ = server;
|
||||
if (!server.isEmpty ())
|
||||
{
|
||||
// queue a host address lookup
|
||||
QHostInfo::lookupHost (server, &*m_, SLOT (host_info_results (QHostInfo)));
|
||||
}
|
||||
}
|
||||
|
||||
void MessageClient::set_server_port (port_type server_port)
|
||||
{
|
||||
m_->server_port_ = server_port;
|
||||
}
|
||||
|
||||
void MessageClient::send_raw_datagram (QByteArray const& message, QHostAddress const& dest_address
|
||||
, port_type dest_port)
|
||||
{
|
||||
if (dest_port && !dest_address.isNull ())
|
||||
{
|
||||
m_->writeDatagram (message, dest_address, dest_port);
|
||||
}
|
||||
}
|
||||
|
||||
void MessageClient::status_update (Frequency f, QString const& mode, QString const& dx_call
|
||||
, QString const& report, QString const& tx_mode
|
||||
, bool tx_enabled, bool transmitting, bool decoding
|
||||
, qint32 rx_df, qint32 tx_df, QString const& de_call
|
||||
, QString const& de_grid, QString const& dx_grid
|
||||
, bool watchdog_timeout, QString const& sub_mode
|
||||
, bool fast_mode)
|
||||
{
|
||||
if (m_->server_port_ && !m_->server_string_.isEmpty ())
|
||||
{
|
||||
QByteArray message;
|
||||
NetworkMessage::Builder out {&message, NetworkMessage::Status, m_->id_, m_->schema_};
|
||||
out << f << mode.toUtf8 () << dx_call.toUtf8 () << report.toUtf8 () << tx_mode.toUtf8 ()
|
||||
<< tx_enabled << transmitting << decoding << rx_df << tx_df << de_call.toUtf8 ()
|
||||
<< de_grid.toUtf8 () << dx_grid.toUtf8 () << watchdog_timeout << sub_mode.toUtf8 ()
|
||||
<< fast_mode;
|
||||
m_->send_message (out, message);
|
||||
}
|
||||
}
|
||||
|
||||
void MessageClient::decode (bool is_new, QTime time, qint32 snr, float delta_time, quint32 delta_frequency
|
||||
, QString const& mode, QString const& message_text)
|
||||
{
|
||||
if (m_->server_port_ && !m_->server_string_.isEmpty ())
|
||||
{
|
||||
QByteArray message;
|
||||
NetworkMessage::Builder out {&message, NetworkMessage::Decode, m_->id_, m_->schema_};
|
||||
out << is_new << time << snr << delta_time << delta_frequency << mode.toUtf8 () << message_text.toUtf8 ();
|
||||
m_->send_message (out, message);
|
||||
}
|
||||
}
|
||||
|
||||
void MessageClient::WSPR_decode (bool is_new, QTime time, qint32 snr, float delta_time, Frequency frequency
|
||||
, qint32 drift, QString const& callsign, QString const& grid, qint32 power)
|
||||
{
|
||||
if (m_->server_port_ && !m_->server_string_.isEmpty ())
|
||||
{
|
||||
QByteArray message;
|
||||
NetworkMessage::Builder out {&message, NetworkMessage::WSPRDecode, m_->id_, m_->schema_};
|
||||
out << is_new << time << snr << delta_time << frequency << drift << callsign.toUtf8 ()
|
||||
<< grid.toUtf8 () << power;
|
||||
m_->send_message (out, message);
|
||||
}
|
||||
}
|
||||
|
||||
void MessageClient::clear_decodes ()
|
||||
{
|
||||
if (m_->server_port_ && !m_->server_string_.isEmpty ())
|
||||
{
|
||||
QByteArray message;
|
||||
NetworkMessage::Builder out {&message, NetworkMessage::Clear, m_->id_, m_->schema_};
|
||||
m_->send_message (out, message);
|
||||
}
|
||||
}
|
||||
|
||||
void MessageClient::qso_logged (QDateTime timeOff, QString const& dx_call, QString const& dx_grid
|
||||
, Frequency dial_frequency, QString const& mode, QString const& report_sent
|
||||
, QString const& report_received, QString const& tx_power
|
||||
, QString const& comments, QString const& name, QDateTime timeOn)
|
||||
{
|
||||
if (m_->server_port_ && !m_->server_string_.isEmpty ())
|
||||
{
|
||||
QByteArray message;
|
||||
NetworkMessage::Builder out {&message, NetworkMessage::QSOLogged, m_->id_, m_->schema_};
|
||||
out << timeOff << dx_call.toUtf8 () << dx_grid.toUtf8 () << dial_frequency << mode.toUtf8 ()
|
||||
<< report_sent.toUtf8 () << report_received.toUtf8 () << tx_power.toUtf8 () << comments.toUtf8 () << name.toUtf8 () << timeOn;
|
||||
m_->send_message (out, message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
subroutine softsym9w(id2,npts,xdt0,f0,width,nsubmode,xdt1,i1softsymbols)
|
||||
|
||||
parameter (NFFT=6912,NH=NFFT/2,NQ=NH/2)
|
||||
real s(NQ)
|
||||
real s2(0:8,85)
|
||||
real s3(0:7,69)
|
||||
real x(NFFT)
|
||||
complex cx(0:NH)
|
||||
integer*2 id2(60*12000)
|
||||
integer*1 i1SoftSymbolsScrambled(207)
|
||||
integer*1 i1softsymbols(207)
|
||||
include 'jt9sync.f90'
|
||||
equivalence (x,cx)
|
||||
|
||||
if(npts.eq.-99) stop !Silence compiler warning
|
||||
df=12000.0/NFFT
|
||||
i0a=max(1.0,(xdt0-1.0)*12000.0)
|
||||
i0b=(xdt0+1.0)*12000.0
|
||||
k1=max(1,nint((f0-0.5*width)/df))
|
||||
k2=min(NQ,nint((f0+0.5*width)/df))
|
||||
smax=0.
|
||||
i0pk=1
|
||||
i1softsymbols=0
|
||||
|
||||
do i0=i0a,i0b,432
|
||||
s=0.
|
||||
ssum=0.
|
||||
do j=1,16
|
||||
ia=i0 + (ii(j)-1)*nfft
|
||||
ib=ia+NFFT-1
|
||||
x=1.e-6*id2(ia:ib)
|
||||
call four2a(x,nfft,1,-1,0) !r2c FFT
|
||||
do k=1,NQ
|
||||
s(k)=s(k) + real(cx(k))**2 + aimag(cx(k))**2
|
||||
enddo
|
||||
enddo
|
||||
ssum=ssum + sum(s(k1:k2))
|
||||
if(ssum.gt.smax) then
|
||||
smax=ssum
|
||||
i0pk=i0
|
||||
else
|
||||
if(ssum.lt.0.7*smax) exit
|
||||
endif
|
||||
end do
|
||||
xdt1=(i0pk-1)/12000.0
|
||||
|
||||
if(i0pk.le.0) go to 999
|
||||
|
||||
m=0
|
||||
do j=1,85
|
||||
ia=i0pk + (j-1)*nfft
|
||||
ib=ia+NFFT-1
|
||||
x=1.e-6*id2(ia:ib)
|
||||
call four2a(x,nfft,1,-1,0) !r2c FFT
|
||||
do k=1,NQ
|
||||
s(k)=real(cx(k))**2 + aimag(cx(k))**2
|
||||
enddo
|
||||
|
||||
dtone=df*(2**nsubmode)
|
||||
do i=0,8
|
||||
f=f0 + i*dtone
|
||||
k1=max(1,nint((f-0.5*width)/df))
|
||||
k2=min(NQ,nint((f+0.5*width)/df))
|
||||
s2(i,j)=sum(s(k1:k2)) !Symbol spectra, including sync
|
||||
enddo
|
||||
|
||||
if(isync(j).eq.0) then
|
||||
m=m+1
|
||||
s3(0:7,m)=s2(1:8,j) !Symbol spectra, data only
|
||||
endif
|
||||
|
||||
! write(19,3101) j,s2(0:8,j)
|
||||
!3101 format(i2,9f8.2)
|
||||
enddo
|
||||
|
||||
ss=0.
|
||||
sig=0.
|
||||
do j=1,69
|
||||
smax=0.
|
||||
do i=0,7
|
||||
smax=max(smax,s3(i,j))
|
||||
ss=ss+s3(i,j)
|
||||
enddo
|
||||
sig=sig+smax
|
||||
ss=ss-smax
|
||||
enddo
|
||||
ave=ss/(69*7) !Baseline
|
||||
call pctile(s2,9*85,35,xmed)
|
||||
s3=s3/ave
|
||||
sig=sig/69. !Signal
|
||||
t=max(1.0,sig - 1.0)
|
||||
snrdb=db(t)
|
||||
|
||||
m0=3
|
||||
k=0
|
||||
do j=1,69
|
||||
smax=0.
|
||||
do i=0,7
|
||||
if(s3(i,j).gt.smax) smax=s3(i,j)
|
||||
enddo
|
||||
|
||||
do m=m0-1,0,-1 !Get bit-wise soft symbols
|
||||
if(m.eq.2) then
|
||||
r1=max(s3(4,j),s3(5,j),s3(6,j),s3(7,j))
|
||||
r0=max(s3(0,j),s3(1,j),s3(2,j),s3(3,j))
|
||||
else if(m.eq.1) then
|
||||
r1=max(s3(2,j),s3(3,j),s3(4,j),s3(5,j))
|
||||
r0=max(s3(0,j),s3(1,j),s3(6,j),s3(7,j))
|
||||
else
|
||||
r1=max(s3(1,j),s3(2,j),s3(4,j),s3(7,j))
|
||||
r0=max(s3(0,j),s3(3,j),s3(5,j),s3(6,j))
|
||||
endif
|
||||
|
||||
k=k+1
|
||||
i4=nint(10.0*(r1-r0))
|
||||
if(i4.lt.-127) i4=-127
|
||||
if(i4.gt.127) i4=127
|
||||
i1SoftSymbolsScrambled(k)=i4
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! Remove interleaving
|
||||
call interleave9(i1SoftSymbolsScrambled,-1,i1SoftSymbols)
|
||||
|
||||
999 return
|
||||
end subroutine softsym9w
|
||||
@@ -0,0 +1,31 @@
|
||||
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
|
||||
// unit/quantity manipulation and conversion
|
||||
//
|
||||
// Copyright (C) 2003-2008 Matthias Christian Schabel
|
||||
// Copyright (C) 2008 Steven Watanabe
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_UNITS_SI_RESISTIVITY_HPP
|
||||
#define BOOST_UNITS_SI_RESISTIVITY_HPP
|
||||
|
||||
#include <boost/units/systems/si/base.hpp>
|
||||
#include <boost/units/physical_dimensions/resistivity.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace units {
|
||||
|
||||
namespace si {
|
||||
|
||||
typedef unit<resistivity_dimension,si::system> resistivity;
|
||||
|
||||
} // namespace si
|
||||
|
||||
} // namespace units
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_UNITS_SI_RESISTIVITY_HPP
|
||||
@@ -0,0 +1,28 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2007 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
#ifndef BOOST_PHOENIX_CORE_AS_ACTOR_HPP
|
||||
#define BOOST_PHOENIX_CORE_AS_ACTOR_HPP
|
||||
|
||||
#include <boost/phoenix/core/actor.hpp>
|
||||
#include <boost/fusion/support/void.hpp>
|
||||
|
||||
namespace boost { namespace phoenix
|
||||
{
|
||||
template <typename T, typename U = typename is_actor<T>::type >
|
||||
struct as_actor
|
||||
{
|
||||
typedef T type;
|
||||
|
||||
static type const &
|
||||
convert(T const & t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,111 @@
|
||||
program wspr5sim
|
||||
|
||||
! Generate simulated data for a 5-minute "WSPR-LF" mode. Output is saved
|
||||
! to a *.c5 or *.wav file.
|
||||
|
||||
use wavhdr
|
||||
include 'wsprlf_params.f90' !Set various constants
|
||||
parameter (NMAX=300*12000)
|
||||
type(hdr) h !Header for .wav file
|
||||
character arg*12,fname*16
|
||||
character msg*22,msgsent*22
|
||||
complex c0(0:NZ-1)
|
||||
complex c(0:NZ-1)
|
||||
real*8 fMHz
|
||||
integer itone(NN)
|
||||
integer*2 iwave(NMAX) !Generated full-length waveform
|
||||
|
||||
! Get command-line argument(s)
|
||||
nargs=iargc()
|
||||
if(nargs.ne.8) then
|
||||
print*,'Usage: wspr5sim "message" f0 DT fsp del nwav nfiles snr'
|
||||
print*,'Example: wspr5sim "K1ABC FN42 30" 50 0.0 0.1 1.0 1 10 -33'
|
||||
go to 999
|
||||
endif
|
||||
call getarg(1,msg) !Message to be transmitted
|
||||
call getarg(2,arg)
|
||||
read(arg,*) f0 !Freq relative to WSPR-band center (Hz)
|
||||
call getarg(3,arg)
|
||||
read(arg,*) xdt !Time offset from nominal (s)
|
||||
call getarg(4,arg)
|
||||
read(arg,*) fspread !Watterson frequency spread (Hz)
|
||||
call getarg(5,arg)
|
||||
read(arg,*) delay !Watterson delay (ms)
|
||||
call getarg(6,arg)
|
||||
read(arg,*) nwav !1 for *.wav file, 0 for *.c5 file
|
||||
call getarg(7,arg)
|
||||
read(arg,*) nfiles !Number of files
|
||||
call getarg(8,arg)
|
||||
read(arg,*) snrdb !SNR_2500
|
||||
|
||||
twopi=8.0*atan(1.0)
|
||||
fs=12000.0/NDOWN !Sample rate
|
||||
dt=1.0/fs !Sample interval (s)
|
||||
tt=NSPS*dt !Duration of "itone" symbols (s)
|
||||
ts=2*NSPS*dt !Duration of OQPSK symbols (s)
|
||||
baud=1.0/tt !Keying rate for "itone" symbols (baud)
|
||||
txt=NZ*dt !Transmission length (s)
|
||||
bandwidth_ratio=2500.0/(fs/2.0)
|
||||
sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb)
|
||||
if(snrdb.gt.90.0) sig=1.0
|
||||
txt=NN*NSPS0/12000.0
|
||||
|
||||
call genwspr5(msg,msgsent,itone) !Encode the message, get itone
|
||||
write(*,1000) f0,xdt,txt,snrdb,fspread,delay,nfiles,msgsent
|
||||
1000 format('f0:',f9.3,' DT:',f6.2,' txt:',f6.1,' SNR:',f6.1, &
|
||||
' fspread:',f6.1,' delay:',f6.1,' nfiles:',i3,2x,a22)
|
||||
|
||||
dphi0=twopi*(f0-0.25*baud)*dt
|
||||
dphi1=twopi*(f0+0.25*baud)*dt
|
||||
phi=0.0
|
||||
c0=0.
|
||||
k=-1 + nint(xdt/dt)
|
||||
do j=1,NN !Generate OQPSK waveform from itone
|
||||
dphi=dphi0
|
||||
if(itone(j).eq.1) dphi=dphi1
|
||||
if(k.eq.0) phi=-dphi
|
||||
do i=1,NSPS
|
||||
k=k+1
|
||||
phi=phi+dphi
|
||||
if(phi.gt.twopi) phi=phi-twopi
|
||||
xphi=phi
|
||||
if(k.ge.0 .and. k.lt.NZ) c0(k)=cmplx(cos(xphi),sin(xphi))
|
||||
enddo
|
||||
enddo
|
||||
|
||||
call sgran()
|
||||
do ifile=1,nfiles
|
||||
c=c0
|
||||
if(nwav.eq.0) then
|
||||
if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then
|
||||
call watterson(c,NZ,fs,delay,fspread)
|
||||
endif
|
||||
c=c*sig
|
||||
if(snrdb.lt.90) then
|
||||
do i=0,NZ-1 !Add gaussian noise at specified SNR
|
||||
xnoise=gran()
|
||||
ynoise=gran()
|
||||
c(i)=c(i) + cmplx(xnoise,ynoise)
|
||||
enddo
|
||||
endif
|
||||
write(fname,1100) ifile
|
||||
1100 format('000000_',i4.4,'.c5')
|
||||
open(10,file=fname,status='unknown',access='stream')
|
||||
fMHz=10.1387d0
|
||||
nmin=5
|
||||
write(10) fname,nmin,fMHz,c !Save to *.c5 file
|
||||
close(10)
|
||||
else
|
||||
call wspr5_wav(baud,xdt,f0,itone,snrdb,iwave)
|
||||
h=default_header(12000,NMAX)
|
||||
write(fname,1102) ifile
|
||||
1102 format('000000_',i4.4,'.wav')
|
||||
open(10,file=fname,status='unknown',access='stream')
|
||||
write(10) h,iwave !Save to *.wav file
|
||||
close(10)
|
||||
endif
|
||||
write(*,1110) ifile,xdt,f0,snrdb,fname
|
||||
1110 format(i4,f7.2,f8.2,f7.1,2x,a16)
|
||||
enddo
|
||||
|
||||
999 end program wspr5sim
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,53 @@
|
||||
|
||||
// (C) Copyright Tobias Schwinger
|
||||
//
|
||||
// Use modification and distribution are subject to the boost Software License,
|
||||
// Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// no include guards, this file is intended for multiple inclusion
|
||||
|
||||
// input: BOOST_FT_syntax type macro to use
|
||||
// input: BOOST_FT_cc empty or cc specifier
|
||||
// input: BOOST_FT_ell empty or "..."
|
||||
// input: BOOST_FT_cv empty or cv qualifiers
|
||||
// input: BOOST_FT_flags single decimal integer encoding the flags
|
||||
// output: BOOST_FT_n number of component types (arity+1)
|
||||
// output: BOOST_FT_arity current arity
|
||||
// output: BOOST_FT_type macro that expands to the type
|
||||
// output: BOOST_FT_tplargs(p) template arguments with given prefix
|
||||
// output: BOOST_FT_params(p) parameters with given prefix
|
||||
|
||||
# include <boost/function_types/detail/classifier_impl/arity20_1.hpp>
|
||||
template< typename R , typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 , typename T9 , typename T10 , typename T11 , typename T12 , typename T13 , typename T14 , typename T15 , typename T16 , typename T17 , typename T18 , typename T19 , typename T20 >
|
||||
typename encode_charr<BOOST_FT_flags,BOOST_FT_cc_id,21> ::type
|
||||
classifier_impl(BOOST_FT_syntax(BOOST_FT_cc, BOOST_PP_EMPTY) (T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 , T14 , T15 , T16 , T17 , T18 , T19 , T20 BOOST_FT_ell) BOOST_FT_cv);
|
||||
template< typename R , typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 , typename T9 , typename T10 , typename T11 , typename T12 , typename T13 , typename T14 , typename T15 , typename T16 , typename T17 , typename T18 , typename T19 , typename T20 , typename T21 >
|
||||
typename encode_charr<BOOST_FT_flags,BOOST_FT_cc_id,22> ::type
|
||||
classifier_impl(BOOST_FT_syntax(BOOST_FT_cc, BOOST_PP_EMPTY) (T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 , T14 , T15 , T16 , T17 , T18 , T19 , T20 , T21 BOOST_FT_ell) BOOST_FT_cv);
|
||||
template< typename R , typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 , typename T9 , typename T10 , typename T11 , typename T12 , typename T13 , typename T14 , typename T15 , typename T16 , typename T17 , typename T18 , typename T19 , typename T20 , typename T21 , typename T22 >
|
||||
typename encode_charr<BOOST_FT_flags,BOOST_FT_cc_id,23> ::type
|
||||
classifier_impl(BOOST_FT_syntax(BOOST_FT_cc, BOOST_PP_EMPTY) (T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 , T14 , T15 , T16 , T17 , T18 , T19 , T20 , T21 , T22 BOOST_FT_ell) BOOST_FT_cv);
|
||||
template< typename R , typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 , typename T9 , typename T10 , typename T11 , typename T12 , typename T13 , typename T14 , typename T15 , typename T16 , typename T17 , typename T18 , typename T19 , typename T20 , typename T21 , typename T22 , typename T23 >
|
||||
typename encode_charr<BOOST_FT_flags,BOOST_FT_cc_id,24> ::type
|
||||
classifier_impl(BOOST_FT_syntax(BOOST_FT_cc, BOOST_PP_EMPTY) (T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 , T14 , T15 , T16 , T17 , T18 , T19 , T20 , T21 , T22 , T23 BOOST_FT_ell) BOOST_FT_cv);
|
||||
template< typename R , typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 , typename T9 , typename T10 , typename T11 , typename T12 , typename T13 , typename T14 , typename T15 , typename T16 , typename T17 , typename T18 , typename T19 , typename T20 , typename T21 , typename T22 , typename T23 , typename T24 >
|
||||
typename encode_charr<BOOST_FT_flags,BOOST_FT_cc_id,25> ::type
|
||||
classifier_impl(BOOST_FT_syntax(BOOST_FT_cc, BOOST_PP_EMPTY) (T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 , T14 , T15 , T16 , T17 , T18 , T19 , T20 , T21 , T22 , T23 , T24 BOOST_FT_ell) BOOST_FT_cv);
|
||||
template< typename R , typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 , typename T9 , typename T10 , typename T11 , typename T12 , typename T13 , typename T14 , typename T15 , typename T16 , typename T17 , typename T18 , typename T19 , typename T20 , typename T21 , typename T22 , typename T23 , typename T24 , typename T25 >
|
||||
typename encode_charr<BOOST_FT_flags,BOOST_FT_cc_id,26> ::type
|
||||
classifier_impl(BOOST_FT_syntax(BOOST_FT_cc, BOOST_PP_EMPTY) (T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 , T14 , T15 , T16 , T17 , T18 , T19 , T20 , T21 , T22 , T23 , T24 , T25 BOOST_FT_ell) BOOST_FT_cv);
|
||||
template< typename R , typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 , typename T9 , typename T10 , typename T11 , typename T12 , typename T13 , typename T14 , typename T15 , typename T16 , typename T17 , typename T18 , typename T19 , typename T20 , typename T21 , typename T22 , typename T23 , typename T24 , typename T25 , typename T26 >
|
||||
typename encode_charr<BOOST_FT_flags,BOOST_FT_cc_id,27> ::type
|
||||
classifier_impl(BOOST_FT_syntax(BOOST_FT_cc, BOOST_PP_EMPTY) (T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 , T14 , T15 , T16 , T17 , T18 , T19 , T20 , T21 , T22 , T23 , T24 , T25 , T26 BOOST_FT_ell) BOOST_FT_cv);
|
||||
template< typename R , typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 , typename T9 , typename T10 , typename T11 , typename T12 , typename T13 , typename T14 , typename T15 , typename T16 , typename T17 , typename T18 , typename T19 , typename T20 , typename T21 , typename T22 , typename T23 , typename T24 , typename T25 , typename T26 , typename T27 >
|
||||
typename encode_charr<BOOST_FT_flags,BOOST_FT_cc_id,28> ::type
|
||||
classifier_impl(BOOST_FT_syntax(BOOST_FT_cc, BOOST_PP_EMPTY) (T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 , T14 , T15 , T16 , T17 , T18 , T19 , T20 , T21 , T22 , T23 , T24 , T25 , T26 , T27 BOOST_FT_ell) BOOST_FT_cv);
|
||||
template< typename R , typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 , typename T9 , typename T10 , typename T11 , typename T12 , typename T13 , typename T14 , typename T15 , typename T16 , typename T17 , typename T18 , typename T19 , typename T20 , typename T21 , typename T22 , typename T23 , typename T24 , typename T25 , typename T26 , typename T27 , typename T28 >
|
||||
typename encode_charr<BOOST_FT_flags,BOOST_FT_cc_id,29> ::type
|
||||
classifier_impl(BOOST_FT_syntax(BOOST_FT_cc, BOOST_PP_EMPTY) (T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 , T14 , T15 , T16 , T17 , T18 , T19 , T20 , T21 , T22 , T23 , T24 , T25 , T26 , T27 , T28 BOOST_FT_ell) BOOST_FT_cv);
|
||||
template< typename R , typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 , typename T9 , typename T10 , typename T11 , typename T12 , typename T13 , typename T14 , typename T15 , typename T16 , typename T17 , typename T18 , typename T19 , typename T20 , typename T21 , typename T22 , typename T23 , typename T24 , typename T25 , typename T26 , typename T27 , typename T28 , typename T29 >
|
||||
typename encode_charr<BOOST_FT_flags,BOOST_FT_cc_id,30> ::type
|
||||
classifier_impl(BOOST_FT_syntax(BOOST_FT_cc, BOOST_PP_EMPTY) (T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 , T11 , T12 , T13 , T14 , T15 , T16 , T17 , T18 , T19 , T20 , T21 , T22 , T23 , T24 , T25 , T26 , T27 , T28 , T29 BOOST_FT_ell) BOOST_FT_cv);
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
#ifndef BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_HPP
|
||||
#define BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// xml_unescape.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <boost/serialization/throw_exception.hpp>
|
||||
|
||||
#include <boost/archive/iterators/unescape.hpp>
|
||||
#include <boost/archive/iterators/dataflow_exception.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
namespace iterators {
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// replace &??? xml escape sequences with the corresponding characters
|
||||
template<class Base>
|
||||
class xml_unescape
|
||||
: public unescape<xml_unescape<Base>, Base>
|
||||
{
|
||||
friend class boost::iterator_core_access;
|
||||
typedef xml_unescape<Base> this_t;
|
||||
typedef unescape<this_t, Base> super_t;
|
||||
typedef typename boost::iterator_reference<this_t> reference_type;
|
||||
|
||||
reference_type dereference() const {
|
||||
return unescape<xml_unescape<Base>, Base>::dereference();
|
||||
}
|
||||
public:
|
||||
// workaround msvc 7.1 ICU crash
|
||||
#if defined(BOOST_MSVC)
|
||||
typedef int value_type;
|
||||
#else
|
||||
typedef typename this_t::value_type value_type;
|
||||
#endif
|
||||
|
||||
void drain_residue(const char *literal);
|
||||
value_type drain();
|
||||
|
||||
template<class T>
|
||||
xml_unescape(T start) :
|
||||
super_t(Base(static_cast< T >(start)))
|
||||
{}
|
||||
// intel 7.1 doesn't like default copy constructor
|
||||
xml_unescape(const xml_unescape & rhs) :
|
||||
super_t(rhs.base_reference())
|
||||
{}
|
||||
};
|
||||
|
||||
template<class Base>
|
||||
void xml_unescape<Base>::drain_residue(const char * literal){
|
||||
do{
|
||||
if(* literal != * ++(this->base_reference()))
|
||||
boost::serialization::throw_exception(
|
||||
dataflow_exception(
|
||||
dataflow_exception::invalid_xml_escape_sequence
|
||||
)
|
||||
);
|
||||
}
|
||||
while('\0' != * ++literal);
|
||||
}
|
||||
|
||||
// note key constraint on this function is that can't "look ahead" any
|
||||
// more than necessary into base iterator. Doing so would alter the base
|
||||
// iterator refenence which would make subsequent iterator comparisons
|
||||
// incorrect and thereby break the composiblity of iterators.
|
||||
template<class Base>
|
||||
typename xml_unescape<Base>::value_type
|
||||
//int
|
||||
xml_unescape<Base>::drain(){
|
||||
value_type retval = * this->base_reference();
|
||||
if('&' != retval){
|
||||
return retval;
|
||||
}
|
||||
retval = * ++(this->base_reference());
|
||||
switch(retval){
|
||||
case 'l': // <
|
||||
drain_residue("t;");
|
||||
retval = '<';
|
||||
break;
|
||||
case 'g': // >
|
||||
drain_residue("t;");
|
||||
retval = '>';
|
||||
break;
|
||||
case 'a':
|
||||
retval = * ++(this->base_reference());
|
||||
switch(retval){
|
||||
case 'p': // '
|
||||
drain_residue("os;");
|
||||
retval = '\'';
|
||||
break;
|
||||
case 'm': // &
|
||||
drain_residue("p;");
|
||||
retval = '&';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'q':
|
||||
drain_residue("uot;");
|
||||
retval = '"';
|
||||
break;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
} // namespace iterators
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_HPP
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
#ifndef RETURN_INTERNAL_REFERENCE_DWA2002131_HPP
|
||||
# define RETURN_INTERNAL_REFERENCE_DWA2002131_HPP
|
||||
|
||||
# include <boost/python/detail/prefix.hpp>
|
||||
|
||||
# include <boost/python/default_call_policies.hpp>
|
||||
# include <boost/python/reference_existing_object.hpp>
|
||||
# include <boost/python/with_custodian_and_ward.hpp>
|
||||
# include <boost/mpl/if.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <std::size_t>
|
||||
struct return_internal_reference_owner_arg_must_be_greater_than_zero
|
||||
# if defined(__GNUC__) || defined(__EDG__)
|
||||
{}
|
||||
# endif
|
||||
;
|
||||
}
|
||||
|
||||
template <std::size_t owner_arg = 1, class BasePolicy_ = default_call_policies>
|
||||
struct return_internal_reference
|
||||
: with_custodian_and_ward_postcall<0, owner_arg, BasePolicy_>
|
||||
{
|
||||
private:
|
||||
BOOST_STATIC_CONSTANT(bool, legal = owner_arg > 0);
|
||||
public:
|
||||
typedef typename mpl::if_c<
|
||||
legal
|
||||
, reference_existing_object
|
||||
, detail::return_internal_reference_owner_arg_must_be_greater_than_zero<owner_arg>
|
||||
>::type result_converter;
|
||||
};
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
#endif // RETURN_INTERNAL_REFERENCE_DWA2002131_HPP
|
||||
@@ -0,0 +1,199 @@
|
||||
// Copyright (c) 2006 Xiaogang Zhang
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_MATH_BESSEL_J1_HPP
|
||||
#define BOOST_MATH_BESSEL_J1_HPP
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
#include <boost/math/tools/rational.hpp>
|
||||
#include <boost/math/tools/big_constant.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
// Bessel function of the first kind of order one
|
||||
// x <= 8, minimax rational approximations on root-bracketing intervals
|
||||
// x > 8, Hankel asymptotic expansion in Hart, Computer Approximations, 1968
|
||||
|
||||
namespace boost { namespace math{ namespace detail{
|
||||
|
||||
template <typename T>
|
||||
T bessel_j1(T x);
|
||||
|
||||
template <class T>
|
||||
struct bessel_j1_initializer
|
||||
{
|
||||
struct init
|
||||
{
|
||||
init()
|
||||
{
|
||||
do_init();
|
||||
}
|
||||
static void do_init()
|
||||
{
|
||||
bessel_j1(T(1));
|
||||
}
|
||||
void force_instantiate()const{}
|
||||
};
|
||||
static const init initializer;
|
||||
static void force_instantiate()
|
||||
{
|
||||
initializer.force_instantiate();
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
const typename bessel_j1_initializer<T>::init bessel_j1_initializer<T>::initializer;
|
||||
|
||||
template <typename T>
|
||||
T bessel_j1(T x)
|
||||
{
|
||||
bessel_j1_initializer<T>::force_instantiate();
|
||||
|
||||
static const T P1[] = {
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.4258509801366645672e+11)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 6.6781041261492395835e+09)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.1548696764841276794e+08)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 9.8062904098958257677e+05)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -4.4615792982775076130e+03)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0650724020080236441e+01)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.0767857011487300348e-02))
|
||||
};
|
||||
static const T Q1[] = {
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 4.1868604460820175290e+12)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 4.2091902282580133541e+10)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.0228375140097033958e+08)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 5.9117614494174794095e+05)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0742272239517380498e+03)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 0.0))
|
||||
};
|
||||
static const T P2[] = {
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.7527881995806511112e+16)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.6608531731299018674e+15)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -3.6658018905416665164e+13)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.5580665670910619166e+11)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.8113931269860667829e+09)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 5.0793266148011179143e+06)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -7.5023342220781607561e+03)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 4.6179191852758252278e+00))
|
||||
};
|
||||
static const T Q2[] = {
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.7253905888447681194e+18)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.7128800897135812012e+16)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 8.4899346165481429307e+13)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.7622777286244082666e+11)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 6.4872502899596389593e+08)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.1267125065029138050e+06)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.3886978985861357615e+03)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0))
|
||||
};
|
||||
static const T PC[] = {
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -4.4357578167941278571e+06)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -9.9422465050776411957e+06)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -6.6033732483649391093e+06)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.5235293511811373833e+06)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.0982405543459346727e+05)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.6116166443246101165e+03)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 0.0))
|
||||
};
|
||||
static const T QC[] = {
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -4.4357578167941278568e+06)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -9.9341243899345856590e+06)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -6.5853394797230870728e+06)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.5118095066341608816e+06)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.0726385991103820119e+05)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.4550094401904961825e+03)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0))
|
||||
};
|
||||
static const T PS[] = {
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.3220913409857223519e+04)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 8.5145160675335701966e+04)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 6.6178836581270835179e+04)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.8494262873223866797e+04)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.7063754290207680021e+03)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.5265133846636032186e+01)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 0.0))
|
||||
};
|
||||
static const T QS[] = {
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 7.0871281941028743574e+05)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.8194580422439972989e+06)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.4194606696037208929e+06)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 4.0029443582266975117e+05)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.7890229745772202641e+04)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 8.6383677696049909675e+02)),
|
||||
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0))
|
||||
};
|
||||
static const T x1 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.8317059702075123156e+00)),
|
||||
x2 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 7.0155866698156187535e+00)),
|
||||
x11 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 9.810e+02)),
|
||||
x12 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -3.2527979248768438556e-04)),
|
||||
x21 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.7960e+03)),
|
||||
x22 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -3.8330184381246462950e-05));
|
||||
|
||||
T value, factor, r, rc, rs, w;
|
||||
|
||||
BOOST_MATH_STD_USING
|
||||
using namespace boost::math::tools;
|
||||
using namespace boost::math::constants;
|
||||
|
||||
w = abs(x);
|
||||
if (x == 0)
|
||||
{
|
||||
return static_cast<T>(0);
|
||||
}
|
||||
if (w <= 4) // w in (0, 4]
|
||||
{
|
||||
T y = x * x;
|
||||
BOOST_ASSERT(sizeof(P1) == sizeof(Q1));
|
||||
r = evaluate_rational(P1, Q1, y);
|
||||
factor = w * (w + x1) * ((w - x11/256) - x12);
|
||||
value = factor * r;
|
||||
}
|
||||
else if (w <= 8) // w in (4, 8]
|
||||
{
|
||||
T y = x * x;
|
||||
BOOST_ASSERT(sizeof(P2) == sizeof(Q2));
|
||||
r = evaluate_rational(P2, Q2, y);
|
||||
factor = w * (w + x2) * ((w - x21/256) - x22);
|
||||
value = factor * r;
|
||||
}
|
||||
else // w in (8, \infty)
|
||||
{
|
||||
T y = 8 / w;
|
||||
T y2 = y * y;
|
||||
BOOST_ASSERT(sizeof(PC) == sizeof(QC));
|
||||
BOOST_ASSERT(sizeof(PS) == sizeof(QS));
|
||||
rc = evaluate_rational(PC, QC, y2);
|
||||
rs = evaluate_rational(PS, QS, y2);
|
||||
factor = 1 / (sqrt(w) * constants::root_pi<T>());
|
||||
//
|
||||
// What follows is really just:
|
||||
//
|
||||
// T z = w - 0.75f * pi<T>();
|
||||
// value = factor * (rc * cos(z) - y * rs * sin(z));
|
||||
//
|
||||
// but using the sin/cos addition rules plus constants
|
||||
// for the values of sin/cos of 3PI/4 which then cancel
|
||||
// out with corresponding terms in "factor".
|
||||
//
|
||||
T sx = sin(x);
|
||||
T cx = cos(x);
|
||||
value = factor * (rc * (sx - cx) + y * rs * (sx + cx));
|
||||
}
|
||||
|
||||
if (x < 0)
|
||||
{
|
||||
value *= -1; // odd function
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
}}} // namespaces
|
||||
|
||||
#endif // BOOST_MATH_BESSEL_J1_HPP
|
||||
|
||||
@@ -0,0 +1,792 @@
|
||||
|
||||
// Copyright Christopher Kormanyos 2002 - 2011.
|
||||
// Copyright 2011 John Maddock. Distributed under the Boost
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// This work is based on an earlier work:
|
||||
// "Algorithm 910: A Portable C++ Multiple-Precision System for Special-Function Calculations",
|
||||
// in ACM TOMS, {VOL 37, ISSUE 4, (February 2011)} (C) ACM, 2011. http://doi.acm.org/10.1145/1916461.1916469
|
||||
//
|
||||
// This file has no include guards or namespaces - it's expanded inline inside default_ops.hpp
|
||||
//
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:6326) // comparison of two constants
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
void hyp0F1(T& result, const T& b, const T& x)
|
||||
{
|
||||
typedef typename boost::multiprecision::detail::canonical<boost::int32_t, T>::type si_type;
|
||||
typedef typename boost::multiprecision::detail::canonical<boost::uint32_t, T>::type ui_type;
|
||||
|
||||
// Compute the series representation of Hypergeometric0F1 taken from
|
||||
// http://functions.wolfram.com/HypergeometricFunctions/Hypergeometric0F1/06/01/01/
|
||||
// There are no checks on input range or parameter boundaries.
|
||||
|
||||
T x_pow_n_div_n_fact(x);
|
||||
T pochham_b (b);
|
||||
T bp (b);
|
||||
|
||||
eval_divide(result, x_pow_n_div_n_fact, pochham_b);
|
||||
eval_add(result, ui_type(1));
|
||||
|
||||
si_type n;
|
||||
|
||||
T tol;
|
||||
tol = ui_type(1);
|
||||
eval_ldexp(tol, tol, 1 - boost::multiprecision::detail::digits2<number<T, et_on> >::value());
|
||||
eval_multiply(tol, result);
|
||||
if(eval_get_sign(tol) < 0)
|
||||
tol.negate();
|
||||
T term;
|
||||
|
||||
const int series_limit =
|
||||
boost::multiprecision::detail::digits2<number<T, et_on> >::value() < 100
|
||||
? 100 : boost::multiprecision::detail::digits2<number<T, et_on> >::value();
|
||||
// Series expansion of hyperg_0f1(; b; x).
|
||||
for(n = 2; n < series_limit; ++n)
|
||||
{
|
||||
eval_multiply(x_pow_n_div_n_fact, x);
|
||||
eval_divide(x_pow_n_div_n_fact, n);
|
||||
eval_increment(bp);
|
||||
eval_multiply(pochham_b, bp);
|
||||
|
||||
eval_divide(term, x_pow_n_div_n_fact, pochham_b);
|
||||
eval_add(result, term);
|
||||
|
||||
bool neg_term = eval_get_sign(term) < 0;
|
||||
if(neg_term)
|
||||
term.negate();
|
||||
if(term.compare(tol) <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if(n >= series_limit)
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error("H0F1 Failed to Converge"));
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void eval_sin(T& result, const T& x)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(number_category<T>::value == number_kind_floating_point, "The sin function is only valid for floating point types.");
|
||||
if(&result == &x)
|
||||
{
|
||||
T temp;
|
||||
eval_sin(temp, x);
|
||||
result = temp;
|
||||
return;
|
||||
}
|
||||
|
||||
typedef typename boost::multiprecision::detail::canonical<boost::int32_t, T>::type si_type;
|
||||
typedef typename boost::multiprecision::detail::canonical<boost::uint32_t, T>::type ui_type;
|
||||
typedef typename mpl::front<typename T::float_types>::type fp_type;
|
||||
|
||||
switch(eval_fpclassify(x))
|
||||
{
|
||||
case FP_INFINITE:
|
||||
case FP_NAN:
|
||||
if(std::numeric_limits<number<T, et_on> >::has_quiet_NaN)
|
||||
result = std::numeric_limits<number<T, et_on> >::quiet_NaN().backend();
|
||||
else
|
||||
BOOST_THROW_EXCEPTION(std::domain_error("Result is undefined or complex and there is no NaN for this number type."));
|
||||
return;
|
||||
case FP_ZERO:
|
||||
result = ui_type(0);
|
||||
return;
|
||||
default: ;
|
||||
}
|
||||
|
||||
// Local copy of the argument
|
||||
T xx = x;
|
||||
|
||||
// Analyze and prepare the phase of the argument.
|
||||
// Make a local, positive copy of the argument, xx.
|
||||
// The argument xx will be reduced to 0 <= xx <= pi/2.
|
||||
bool b_negate_sin = false;
|
||||
|
||||
if(eval_get_sign(x) < 0)
|
||||
{
|
||||
xx.negate();
|
||||
b_negate_sin = !b_negate_sin;
|
||||
}
|
||||
|
||||
T n_pi, t;
|
||||
// Remove even multiples of pi.
|
||||
if(xx.compare(get_constant_pi<T>()) > 0)
|
||||
{
|
||||
eval_divide(n_pi, xx, get_constant_pi<T>());
|
||||
eval_trunc(n_pi, n_pi);
|
||||
t = ui_type(2);
|
||||
eval_fmod(t, n_pi, t);
|
||||
const bool b_n_pi_is_even = eval_get_sign(t) == 0;
|
||||
eval_multiply(n_pi, get_constant_pi<T>());
|
||||
eval_subtract(xx, n_pi);
|
||||
|
||||
BOOST_MATH_INSTRUMENT_CODE(xx.str(0, std::ios_base::scientific));
|
||||
BOOST_MATH_INSTRUMENT_CODE(n_pi.str(0, std::ios_base::scientific));
|
||||
|
||||
// Adjust signs if the multiple of pi is not even.
|
||||
if(!b_n_pi_is_even)
|
||||
{
|
||||
b_negate_sin = !b_negate_sin;
|
||||
}
|
||||
}
|
||||
|
||||
// Reduce the argument to 0 <= xx <= pi/2.
|
||||
eval_ldexp(t, get_constant_pi<T>(), -1);
|
||||
if(xx.compare(t) > 0)
|
||||
{
|
||||
eval_subtract(xx, get_constant_pi<T>(), xx);
|
||||
BOOST_MATH_INSTRUMENT_CODE(xx.str(0, std::ios_base::scientific));
|
||||
}
|
||||
|
||||
eval_subtract(t, xx);
|
||||
const bool b_zero = eval_get_sign(xx) == 0;
|
||||
const bool b_pi_half = eval_get_sign(t) == 0;
|
||||
|
||||
// Check if the reduced argument is very close to 0 or pi/2.
|
||||
const bool b_near_zero = xx.compare(fp_type(1e-1)) < 0;
|
||||
const bool b_near_pi_half = t.compare(fp_type(1e-1)) < 0;;
|
||||
|
||||
if(b_zero)
|
||||
{
|
||||
result = ui_type(0);
|
||||
}
|
||||
else if(b_pi_half)
|
||||
{
|
||||
result = ui_type(1);
|
||||
}
|
||||
else if(b_near_zero)
|
||||
{
|
||||
eval_multiply(t, xx, xx);
|
||||
eval_divide(t, si_type(-4));
|
||||
T t2;
|
||||
t2 = fp_type(1.5);
|
||||
hyp0F1(result, t2, t);
|
||||
BOOST_MATH_INSTRUMENT_CODE(result.str(0, std::ios_base::scientific));
|
||||
eval_multiply(result, xx);
|
||||
}
|
||||
else if(b_near_pi_half)
|
||||
{
|
||||
eval_multiply(t, t);
|
||||
eval_divide(t, si_type(-4));
|
||||
T t2;
|
||||
t2 = fp_type(0.5);
|
||||
hyp0F1(result, t2, t);
|
||||
BOOST_MATH_INSTRUMENT_CODE(result.str(0, std::ios_base::scientific));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Scale to a small argument for an efficient Taylor series,
|
||||
// implemented as a hypergeometric function. Use a standard
|
||||
// divide by three identity a certain number of times.
|
||||
// Here we use division by 3^9 --> (19683 = 3^9).
|
||||
|
||||
static const si_type n_scale = 9;
|
||||
static const si_type n_three_pow_scale = static_cast<si_type>(19683L);
|
||||
|
||||
eval_divide(xx, n_three_pow_scale);
|
||||
|
||||
// Now with small arguments, we are ready for a series expansion.
|
||||
eval_multiply(t, xx, xx);
|
||||
eval_divide(t, si_type(-4));
|
||||
T t2;
|
||||
t2 = fp_type(1.5);
|
||||
hyp0F1(result, t2, t);
|
||||
BOOST_MATH_INSTRUMENT_CODE(result.str(0, std::ios_base::scientific));
|
||||
eval_multiply(result, xx);
|
||||
|
||||
// Convert back using multiple angle identity.
|
||||
for(boost::int32_t k = static_cast<boost::int32_t>(0); k < n_scale; k++)
|
||||
{
|
||||
// Rescale the cosine value using the multiple angle identity.
|
||||
eval_multiply(t2, result, ui_type(3));
|
||||
eval_multiply(t, result, result);
|
||||
eval_multiply(t, result);
|
||||
eval_multiply(t, ui_type(4));
|
||||
eval_subtract(result, t2, t);
|
||||
}
|
||||
}
|
||||
|
||||
if(b_negate_sin)
|
||||
result.negate();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void eval_cos(T& result, const T& x)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(number_category<T>::value == number_kind_floating_point, "The cos function is only valid for floating point types.");
|
||||
if(&result == &x)
|
||||
{
|
||||
T temp;
|
||||
eval_cos(temp, x);
|
||||
result = temp;
|
||||
return;
|
||||
}
|
||||
|
||||
typedef typename boost::multiprecision::detail::canonical<boost::int32_t, T>::type si_type;
|
||||
typedef typename boost::multiprecision::detail::canonical<boost::uint32_t, T>::type ui_type;
|
||||
typedef typename mpl::front<typename T::float_types>::type fp_type;
|
||||
|
||||
switch(eval_fpclassify(x))
|
||||
{
|
||||
case FP_INFINITE:
|
||||
case FP_NAN:
|
||||
if(std::numeric_limits<number<T, et_on> >::has_quiet_NaN)
|
||||
result = std::numeric_limits<number<T, et_on> >::quiet_NaN().backend();
|
||||
else
|
||||
BOOST_THROW_EXCEPTION(std::domain_error("Result is undefined or complex and there is no NaN for this number type."));
|
||||
return;
|
||||
case FP_ZERO:
|
||||
result = ui_type(1);
|
||||
return;
|
||||
default: ;
|
||||
}
|
||||
|
||||
// Local copy of the argument
|
||||
T xx = x;
|
||||
|
||||
// Analyze and prepare the phase of the argument.
|
||||
// Make a local, positive copy of the argument, xx.
|
||||
// The argument xx will be reduced to 0 <= xx <= pi/2.
|
||||
bool b_negate_cos = false;
|
||||
|
||||
if(eval_get_sign(x) < 0)
|
||||
{
|
||||
xx.negate();
|
||||
}
|
||||
|
||||
T n_pi, t;
|
||||
// Remove even multiples of pi.
|
||||
if(xx.compare(get_constant_pi<T>()) > 0)
|
||||
{
|
||||
eval_divide(t, xx, get_constant_pi<T>());
|
||||
eval_trunc(n_pi, t);
|
||||
BOOST_MATH_INSTRUMENT_CODE(n_pi.str(0, std::ios_base::scientific));
|
||||
eval_multiply(t, n_pi, get_constant_pi<T>());
|
||||
BOOST_MATH_INSTRUMENT_CODE(t.str(0, std::ios_base::scientific));
|
||||
eval_subtract(xx, t);
|
||||
BOOST_MATH_INSTRUMENT_CODE(xx.str(0, std::ios_base::scientific));
|
||||
|
||||
// Adjust signs if the multiple of pi is not even.
|
||||
t = ui_type(2);
|
||||
eval_fmod(t, n_pi, t);
|
||||
const bool b_n_pi_is_even = eval_get_sign(t) == 0;
|
||||
|
||||
if(!b_n_pi_is_even)
|
||||
{
|
||||
b_negate_cos = !b_negate_cos;
|
||||
}
|
||||
}
|
||||
|
||||
// Reduce the argument to 0 <= xx <= pi/2.
|
||||
eval_ldexp(t, get_constant_pi<T>(), -1);
|
||||
int com = xx.compare(t);
|
||||
if(com > 0)
|
||||
{
|
||||
eval_subtract(xx, get_constant_pi<T>(), xx);
|
||||
b_negate_cos = !b_negate_cos;
|
||||
BOOST_MATH_INSTRUMENT_CODE(xx.str(0, std::ios_base::scientific));
|
||||
}
|
||||
|
||||
const bool b_zero = eval_get_sign(xx) == 0;
|
||||
const bool b_pi_half = com == 0;
|
||||
|
||||
// Check if the reduced argument is very close to 0.
|
||||
const bool b_near_zero = xx.compare(fp_type(1e-1)) < 0;
|
||||
|
||||
if(b_zero)
|
||||
{
|
||||
result = si_type(1);
|
||||
}
|
||||
else if(b_pi_half)
|
||||
{
|
||||
result = si_type(0);
|
||||
}
|
||||
else if(b_near_zero)
|
||||
{
|
||||
eval_multiply(t, xx, xx);
|
||||
eval_divide(t, si_type(-4));
|
||||
n_pi = fp_type(0.5f);
|
||||
hyp0F1(result, n_pi, t);
|
||||
BOOST_MATH_INSTRUMENT_CODE(result.str(0, std::ios_base::scientific));
|
||||
}
|
||||
else
|
||||
{
|
||||
eval_subtract(t, xx);
|
||||
eval_sin(result, t);
|
||||
}
|
||||
if(b_negate_cos)
|
||||
result.negate();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void eval_tan(T& result, const T& x)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(number_category<T>::value == number_kind_floating_point, "The tan function is only valid for floating point types.");
|
||||
if(&result == &x)
|
||||
{
|
||||
T temp;
|
||||
eval_tan(temp, x);
|
||||
result = temp;
|
||||
return;
|
||||
}
|
||||
T t;
|
||||
eval_sin(result, x);
|
||||
eval_cos(t, x);
|
||||
eval_divide(result, t);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void hyp2F1(T& result, const T& a, const T& b, const T& c, const T& x)
|
||||
{
|
||||
// Compute the series representation of hyperg_2f1 taken from
|
||||
// Abramowitz and Stegun 15.1.1.
|
||||
// There are no checks on input range or parameter boundaries.
|
||||
|
||||
typedef typename boost::multiprecision::detail::canonical<boost::uint32_t, T>::type ui_type;
|
||||
|
||||
T x_pow_n_div_n_fact(x);
|
||||
T pochham_a (a);
|
||||
T pochham_b (b);
|
||||
T pochham_c (c);
|
||||
T ap (a);
|
||||
T bp (b);
|
||||
T cp (c);
|
||||
|
||||
eval_multiply(result, pochham_a, pochham_b);
|
||||
eval_divide(result, pochham_c);
|
||||
eval_multiply(result, x_pow_n_div_n_fact);
|
||||
eval_add(result, ui_type(1));
|
||||
|
||||
T lim;
|
||||
eval_ldexp(lim, result, 1 - boost::multiprecision::detail::digits2<number<T, et_on> >::value());
|
||||
|
||||
if(eval_get_sign(lim) < 0)
|
||||
lim.negate();
|
||||
|
||||
ui_type n;
|
||||
T term;
|
||||
|
||||
const unsigned series_limit =
|
||||
boost::multiprecision::detail::digits2<number<T, et_on> >::value() < 100
|
||||
? 100 : boost::multiprecision::detail::digits2<number<T, et_on> >::value();
|
||||
// Series expansion of hyperg_2f1(a, b; c; x).
|
||||
for(n = 2; n < series_limit; ++n)
|
||||
{
|
||||
eval_multiply(x_pow_n_div_n_fact, x);
|
||||
eval_divide(x_pow_n_div_n_fact, n);
|
||||
|
||||
eval_increment(ap);
|
||||
eval_multiply(pochham_a, ap);
|
||||
eval_increment(bp);
|
||||
eval_multiply(pochham_b, bp);
|
||||
eval_increment(cp);
|
||||
eval_multiply(pochham_c, cp);
|
||||
|
||||
eval_multiply(term, pochham_a, pochham_b);
|
||||
eval_divide(term, pochham_c);
|
||||
eval_multiply(term, x_pow_n_div_n_fact);
|
||||
eval_add(result, term);
|
||||
|
||||
if(eval_get_sign(term) < 0)
|
||||
term.negate();
|
||||
if(lim.compare(term) >= 0)
|
||||
break;
|
||||
}
|
||||
if(n > series_limit)
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error("H2F1 failed to converge."));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void eval_asin(T& result, const T& x)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(number_category<T>::value == number_kind_floating_point, "The asin function is only valid for floating point types.");
|
||||
typedef typename boost::multiprecision::detail::canonical<boost::uint32_t, T>::type ui_type;
|
||||
typedef typename mpl::front<typename T::float_types>::type fp_type;
|
||||
|
||||
if(&result == &x)
|
||||
{
|
||||
T t(x);
|
||||
eval_asin(result, t);
|
||||
return;
|
||||
}
|
||||
|
||||
switch(eval_fpclassify(x))
|
||||
{
|
||||
case FP_NAN:
|
||||
case FP_INFINITE:
|
||||
if(std::numeric_limits<number<T, et_on> >::has_quiet_NaN)
|
||||
result = std::numeric_limits<number<T, et_on> >::quiet_NaN().backend();
|
||||
else
|
||||
BOOST_THROW_EXCEPTION(std::domain_error("Result is undefined or complex and there is no NaN for this number type."));
|
||||
return;
|
||||
case FP_ZERO:
|
||||
result = ui_type(0);
|
||||
return;
|
||||
default: ;
|
||||
}
|
||||
|
||||
const bool b_neg = eval_get_sign(x) < 0;
|
||||
|
||||
T xx(x);
|
||||
if(b_neg)
|
||||
xx.negate();
|
||||
|
||||
int c = xx.compare(ui_type(1));
|
||||
if(c > 0)
|
||||
{
|
||||
if(std::numeric_limits<number<T, et_on> >::has_quiet_NaN)
|
||||
result = std::numeric_limits<number<T, et_on> >::quiet_NaN().backend();
|
||||
else
|
||||
BOOST_THROW_EXCEPTION(std::domain_error("Result is undefined or complex and there is no NaN for this number type."));
|
||||
return;
|
||||
}
|
||||
else if(c == 0)
|
||||
{
|
||||
result = get_constant_pi<T>();
|
||||
eval_ldexp(result, result, -1);
|
||||
if(b_neg)
|
||||
result.negate();
|
||||
return;
|
||||
}
|
||||
|
||||
if(xx.compare(fp_type(1e-4)) < 0)
|
||||
{
|
||||
// http://functions.wolfram.com/ElementaryFunctions/ArcSin/26/01/01/
|
||||
eval_multiply(xx, xx);
|
||||
T t1, t2;
|
||||
t1 = fp_type(0.5f);
|
||||
t2 = fp_type(1.5f);
|
||||
hyp2F1(result, t1, t1, t2, xx);
|
||||
eval_multiply(result, x);
|
||||
return;
|
||||
}
|
||||
else if(xx.compare(fp_type(1 - 1e-4f)) > 0)
|
||||
{
|
||||
T dx1;
|
||||
T t1, t2;
|
||||
eval_subtract(dx1, ui_type(1), xx);
|
||||
t1 = fp_type(0.5f);
|
||||
t2 = fp_type(1.5f);
|
||||
eval_ldexp(dx1, dx1, -1);
|
||||
hyp2F1(result, t1, t1, t2, dx1);
|
||||
eval_ldexp(dx1, dx1, 2);
|
||||
eval_sqrt(t1, dx1);
|
||||
eval_multiply(result, t1);
|
||||
eval_ldexp(t1, get_constant_pi<T>(), -1);
|
||||
result.negate();
|
||||
eval_add(result, t1);
|
||||
if(b_neg)
|
||||
result.negate();
|
||||
return;
|
||||
}
|
||||
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
typedef typename boost::multiprecision::detail::canonical<long double, T>::type guess_type;
|
||||
#else
|
||||
typedef fp_type guess_type;
|
||||
#endif
|
||||
// Get initial estimate using standard math function asin.
|
||||
guess_type dd;
|
||||
eval_convert_to(&dd, xx);
|
||||
|
||||
result = (guess_type)(std::asin(dd));
|
||||
|
||||
// Newton-Raphson iteration, we should double our precision with each iteration,
|
||||
// in practice this seems to not quite work in all cases... so terminate when we
|
||||
// have at least 2/3 of the digits correct on the assumption that the correction
|
||||
// we've just added will finish the job...
|
||||
|
||||
boost::intmax_t current_precision = eval_ilogb(result);
|
||||
boost::intmax_t target_precision = current_precision - 1 - (std::numeric_limits<number<T> >::digits * 2) / 3;
|
||||
|
||||
// Newton-Raphson iteration
|
||||
while(current_precision > target_precision)
|
||||
{
|
||||
T sine, cosine;
|
||||
eval_sin(sine, result);
|
||||
eval_cos(cosine, result);
|
||||
eval_subtract(sine, xx);
|
||||
eval_divide(sine, cosine);
|
||||
eval_subtract(result, sine);
|
||||
current_precision = eval_ilogb(sine);
|
||||
#ifdef FP_ILOGB0
|
||||
if(current_precision == FP_ILOGB0)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
if(b_neg)
|
||||
result.negate();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void eval_acos(T& result, const T& x)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(number_category<T>::value == number_kind_floating_point, "The acos function is only valid for floating point types.");
|
||||
typedef typename boost::multiprecision::detail::canonical<boost::uint32_t, T>::type ui_type;
|
||||
|
||||
switch(eval_fpclassify(x))
|
||||
{
|
||||
case FP_NAN:
|
||||
case FP_INFINITE:
|
||||
if(std::numeric_limits<number<T, et_on> >::has_quiet_NaN)
|
||||
result = std::numeric_limits<number<T, et_on> >::quiet_NaN().backend();
|
||||
else
|
||||
BOOST_THROW_EXCEPTION(std::domain_error("Result is undefined or complex and there is no NaN for this number type."));
|
||||
return;
|
||||
case FP_ZERO:
|
||||
result = get_constant_pi<T>();
|
||||
eval_ldexp(result, result, -1); // divide by two.
|
||||
return;
|
||||
}
|
||||
|
||||
eval_abs(result, x);
|
||||
int c = result.compare(ui_type(1));
|
||||
|
||||
if(c > 0)
|
||||
{
|
||||
if(std::numeric_limits<number<T, et_on> >::has_quiet_NaN)
|
||||
result = std::numeric_limits<number<T, et_on> >::quiet_NaN().backend();
|
||||
else
|
||||
BOOST_THROW_EXCEPTION(std::domain_error("Result is undefined or complex and there is no NaN for this number type."));
|
||||
return;
|
||||
}
|
||||
else if(c == 0)
|
||||
{
|
||||
if(eval_get_sign(x) < 0)
|
||||
result = get_constant_pi<T>();
|
||||
else
|
||||
result = ui_type(0);
|
||||
return;
|
||||
}
|
||||
|
||||
eval_asin(result, x);
|
||||
T t;
|
||||
eval_ldexp(t, get_constant_pi<T>(), -1);
|
||||
eval_subtract(result, t);
|
||||
result.negate();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void eval_atan(T& result, const T& x)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(number_category<T>::value == number_kind_floating_point, "The atan function is only valid for floating point types.");
|
||||
typedef typename boost::multiprecision::detail::canonical<boost::int32_t, T>::type si_type;
|
||||
typedef typename boost::multiprecision::detail::canonical<boost::uint32_t, T>::type ui_type;
|
||||
typedef typename mpl::front<typename T::float_types>::type fp_type;
|
||||
|
||||
switch(eval_fpclassify(x))
|
||||
{
|
||||
case FP_NAN:
|
||||
result = x;
|
||||
return;
|
||||
case FP_ZERO:
|
||||
result = ui_type(0);
|
||||
return;
|
||||
case FP_INFINITE:
|
||||
if(eval_get_sign(x) < 0)
|
||||
{
|
||||
eval_ldexp(result, get_constant_pi<T>(), -1);
|
||||
result.negate();
|
||||
}
|
||||
else
|
||||
eval_ldexp(result, get_constant_pi<T>(), -1);
|
||||
return;
|
||||
default: ;
|
||||
}
|
||||
|
||||
const bool b_neg = eval_get_sign(x) < 0;
|
||||
|
||||
T xx(x);
|
||||
if(b_neg)
|
||||
xx.negate();
|
||||
|
||||
if(xx.compare(fp_type(0.1)) < 0)
|
||||
{
|
||||
T t1, t2, t3;
|
||||
t1 = ui_type(1);
|
||||
t2 = fp_type(0.5f);
|
||||
t3 = fp_type(1.5f);
|
||||
eval_multiply(xx, xx);
|
||||
xx.negate();
|
||||
hyp2F1(result, t1, t2, t3, xx);
|
||||
eval_multiply(result, x);
|
||||
return;
|
||||
}
|
||||
|
||||
if(xx.compare(fp_type(10)) > 0)
|
||||
{
|
||||
T t1, t2, t3;
|
||||
t1 = fp_type(0.5f);
|
||||
t2 = ui_type(1u);
|
||||
t3 = fp_type(1.5f);
|
||||
eval_multiply(xx, xx);
|
||||
eval_divide(xx, si_type(-1), xx);
|
||||
hyp2F1(result, t1, t2, t3, xx);
|
||||
eval_divide(result, x);
|
||||
if(!b_neg)
|
||||
result.negate();
|
||||
eval_ldexp(t1, get_constant_pi<T>(), -1);
|
||||
eval_add(result, t1);
|
||||
if(b_neg)
|
||||
result.negate();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Get initial estimate using standard math function atan.
|
||||
fp_type d;
|
||||
eval_convert_to(&d, xx);
|
||||
result = fp_type(std::atan(d));
|
||||
|
||||
// Newton-Raphson iteration, we should double our precision with each iteration,
|
||||
// in practice this seems to not quite work in all cases... so terminate when we
|
||||
// have at least 2/3 of the digits correct on the assumption that the correction
|
||||
// we've just added will finish the job...
|
||||
|
||||
boost::intmax_t current_precision = eval_ilogb(result);
|
||||
boost::intmax_t target_precision = current_precision - 1 - (std::numeric_limits<number<T> >::digits * 2) / 3;
|
||||
|
||||
T s, c, t;
|
||||
while(current_precision > target_precision)
|
||||
{
|
||||
eval_sin(s, result);
|
||||
eval_cos(c, result);
|
||||
eval_multiply(t, xx, c);
|
||||
eval_subtract(t, s);
|
||||
eval_multiply(s, t, c);
|
||||
eval_add(result, s);
|
||||
current_precision = eval_ilogb(s);
|
||||
#ifdef FP_ILOGB0
|
||||
if(current_precision == FP_ILOGB0)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
if(b_neg)
|
||||
result.negate();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void eval_atan2(T& result, const T& y, const T& x)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(number_category<T>::value == number_kind_floating_point, "The atan2 function is only valid for floating point types.");
|
||||
if(&result == &y)
|
||||
{
|
||||
T temp(y);
|
||||
eval_atan2(result, temp, x);
|
||||
return;
|
||||
}
|
||||
else if(&result == &x)
|
||||
{
|
||||
T temp(x);
|
||||
eval_atan2(result, y, temp);
|
||||
return;
|
||||
}
|
||||
|
||||
typedef typename boost::multiprecision::detail::canonical<boost::uint32_t, T>::type ui_type;
|
||||
|
||||
switch(eval_fpclassify(y))
|
||||
{
|
||||
case FP_NAN:
|
||||
result = y;
|
||||
return;
|
||||
case FP_ZERO:
|
||||
{
|
||||
int c = eval_get_sign(x);
|
||||
if(c < 0)
|
||||
result = get_constant_pi<T>();
|
||||
else if(c >= 0)
|
||||
result = ui_type(0); // Note we allow atan2(0,0) to be zero, even though it's mathematically undefined
|
||||
return;
|
||||
}
|
||||
case FP_INFINITE:
|
||||
{
|
||||
if(eval_fpclassify(x) == FP_INFINITE)
|
||||
{
|
||||
if(std::numeric_limits<number<T, et_on> >::has_quiet_NaN)
|
||||
result = std::numeric_limits<number<T, et_on> >::quiet_NaN().backend();
|
||||
else
|
||||
BOOST_THROW_EXCEPTION(std::domain_error("Result is undefined or complex and there is no NaN for this number type."));
|
||||
}
|
||||
else
|
||||
{
|
||||
eval_ldexp(result, get_constant_pi<T>(), -1);
|
||||
if(eval_get_sign(y) < 0)
|
||||
result.negate();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch(eval_fpclassify(x))
|
||||
{
|
||||
case FP_NAN:
|
||||
result = x;
|
||||
return;
|
||||
case FP_ZERO:
|
||||
{
|
||||
eval_ldexp(result, get_constant_pi<T>(), -1);
|
||||
if(eval_get_sign(y) < 0)
|
||||
result.negate();
|
||||
return;
|
||||
}
|
||||
case FP_INFINITE:
|
||||
if(eval_get_sign(x) > 0)
|
||||
result = ui_type(0);
|
||||
else
|
||||
result = get_constant_pi<T>();
|
||||
if(eval_get_sign(y) < 0)
|
||||
result.negate();
|
||||
return;
|
||||
}
|
||||
|
||||
T xx;
|
||||
eval_divide(xx, y, x);
|
||||
if(eval_get_sign(xx) < 0)
|
||||
xx.negate();
|
||||
|
||||
eval_atan(result, xx);
|
||||
|
||||
// Determine quadrant (sign) based on signs of x, y
|
||||
const bool y_neg = eval_get_sign(y) < 0;
|
||||
const bool x_neg = eval_get_sign(x) < 0;
|
||||
|
||||
if(y_neg != x_neg)
|
||||
result.negate();
|
||||
|
||||
if(x_neg)
|
||||
{
|
||||
if(y_neg)
|
||||
eval_subtract(result, get_constant_pi<T>());
|
||||
else
|
||||
eval_add(result, get_constant_pi<T>());
|
||||
}
|
||||
}
|
||||
template<class T, class A>
|
||||
inline typename enable_if<is_arithmetic<A>, void>::type eval_atan2(T& result, const T& x, const A& a)
|
||||
{
|
||||
typedef typename boost::multiprecision::detail::canonical<A, T>::type canonical_type;
|
||||
typedef typename mpl::if_<is_same<A, canonical_type>, T, canonical_type>::type cast_type;
|
||||
cast_type c;
|
||||
c = a;
|
||||
eval_atan2(result, x, c);
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if<is_arithmetic<A>, void>::type eval_atan2(T& result, const A& x, const T& a)
|
||||
{
|
||||
typedef typename boost::multiprecision::detail::canonical<A, T>::type canonical_type;
|
||||
typedef typename mpl::if_<is_same<A, canonical_type>, T, canonical_type>::type cast_type;
|
||||
cast_type c;
|
||||
c = x;
|
||||
eval_atan2(result, c, a);
|
||||
}
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
@@ -0,0 +1,134 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_MAP_MAIN_07212005_1106)
|
||||
#define FUSION_MAP_MAIN_07212005_1106
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/container/map/map_fwd.hpp>
|
||||
#include <boost/fusion/support/pair.hpp>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Without variadics, we will use the PP version
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(BOOST_FUSION_HAS_VARIADIC_MAP)
|
||||
# include <boost/fusion/container/map/detail/cpp03/map.hpp>
|
||||
#else
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// C++11 interface
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/fusion/container/map/detail/map_impl.hpp>
|
||||
#include <boost/fusion/container/map/detail/begin_impl.hpp>
|
||||
#include <boost/fusion/container/map/detail/end_impl.hpp>
|
||||
#include <boost/fusion/container/map/detail/at_impl.hpp>
|
||||
#include <boost/fusion/container/map/detail/at_key_impl.hpp>
|
||||
#include <boost/fusion/container/map/detail/value_at_impl.hpp>
|
||||
#include <boost/fusion/container/map/detail/value_at_key_impl.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at_c.hpp>
|
||||
#include <boost/fusion/support/is_sequence.hpp>
|
||||
#include <boost/fusion/support/sequence_base.hpp>
|
||||
#include <boost/fusion/support/category_of.hpp>
|
||||
#include <boost/fusion/support/void.hpp>
|
||||
#include <boost/fusion/support/detail/enabler.hpp>
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct map_tag;
|
||||
|
||||
template <typename ...T>
|
||||
struct map : detail::map_impl<0, T...>, sequence_base<map<T...>>
|
||||
{
|
||||
typedef map_tag fusion_tag;
|
||||
typedef detail::map_impl<0, T...> base_type;
|
||||
|
||||
struct category : random_access_traversal_tag, associative_tag {};
|
||||
typedef mpl::int_<base_type::size> size;
|
||||
typedef mpl::false_ is_view;
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
map() {}
|
||||
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
map(map const& seq)
|
||||
: base_type(seq.base())
|
||||
{}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
map(map&& seq)
|
||||
: base_type(std::forward<map>(seq))
|
||||
{}
|
||||
|
||||
template <typename Sequence>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
map(Sequence const& seq
|
||||
, typename enable_if<traits::is_sequence<Sequence>, detail::enabler_>::type = detail::enabler)
|
||||
: base_type(begin(seq), detail::map_impl_from_iterator())
|
||||
{}
|
||||
|
||||
template <typename Sequence>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
map(Sequence& seq
|
||||
, typename enable_if<traits::is_sequence<Sequence>, detail::enabler_>::type = detail::enabler)
|
||||
: base_type(begin(seq), detail::map_impl_from_iterator())
|
||||
{}
|
||||
|
||||
template <typename Sequence>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
map(Sequence&& seq
|
||||
, typename enable_if<traits::is_sequence<Sequence>, detail::enabler_>::type = detail::enabler)
|
||||
: base_type(begin(seq), detail::map_impl_from_iterator())
|
||||
{}
|
||||
|
||||
template <typename First, typename ...T_>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
map(First const& first, T_ const&... rest)
|
||||
: base_type(first, rest...)
|
||||
{}
|
||||
|
||||
template <typename First, typename ...T_>
|
||||
BOOST_FUSION_GPU_ENABLED
|
||||
map(First&& first, T_&&... rest)
|
||||
: base_type(BOOST_FUSION_FWD_ELEM(First, first), BOOST_FUSION_FWD_ELEM(T_, rest)...)
|
||||
{}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
map& operator=(map const& rhs)
|
||||
{
|
||||
base_type::operator=(rhs.base());
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
map& operator=(map&& rhs)
|
||||
{
|
||||
base_type::operator=(std::forward<base_type>(rhs.base()));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Sequence>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
typename enable_if<traits::is_sequence<Sequence>, map&>::type
|
||||
operator=(Sequence const& seq)
|
||||
{
|
||||
base().assign(begin(seq), detail::map_impl_from_iterator());
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
base_type& base() BOOST_NOEXCEPT { return *this; }
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
base_type const& base() const BOOST_NOEXCEPT { return *this; }
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
/* Copyright 2003-2014 Joaquin M Lopez Munoz.
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* See http://www.boost.org/libs/multi_index for library home page.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_MULTI_INDEX_DETAIL_PROMOTES_ARG_HPP
|
||||
#define BOOST_MULTI_INDEX_DETAIL_PROMOTES_ARG_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/type_traits/intrinsics.hpp>
|
||||
|
||||
/* Metafunctions to check if f(arg1,arg2) promotes either arg1 to the type of
|
||||
* arg2 or viceversa. By default, (i.e. if it cannot be determined), no
|
||||
* promotion is assumed.
|
||||
*/
|
||||
|
||||
#if !defined(BOOST_IS_CONVERTIBLE)
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
template<typename F,typename Arg1,typename Arg2>
|
||||
struct promotes_1st_arg:mpl::false_{};
|
||||
|
||||
template<typename F,typename Arg1,typename Arg2>
|
||||
struct promotes_2nd_arg:mpl::false_{};
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/multi_index/detail/is_transparent.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
namespace multi_index{
|
||||
|
||||
namespace detail{
|
||||
|
||||
template<typename F,typename Arg1,typename Arg2>
|
||||
struct promotes_1st_arg:
|
||||
mpl::and_<
|
||||
mpl::not_<is_transparent<F,Arg1,Arg2> >,
|
||||
is_convertible<const Arg1,Arg2>,
|
||||
is_transparent<F,Arg2,Arg2>
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename F,typename Arg1,typename Arg2>
|
||||
struct promotes_2nd_arg:
|
||||
mpl::and_<
|
||||
mpl::not_<is_transparent<F,Arg1,Arg2> >,
|
||||
is_convertible<const Arg2,Arg1>,
|
||||
is_transparent<F,Arg1,Arg1>
|
||||
>
|
||||
{};
|
||||
|
||||
} /* namespace multi_index::detail */
|
||||
|
||||
} /* namespace multi_index */
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
#endif /* defined(BOOST_IS_CONVERTIBLE) */
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
#if !defined(FUSION_SIZE_IMPL_09232005_1058)
|
||||
#define FUSION_SIZE_IMPL_09232005_1058
|
||||
|
||||
#include <boost/fusion/support/config.hpp>
|
||||
#include <boost/fusion/iterator/distance.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct filter_view_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct size_impl;
|
||||
|
||||
template <>
|
||||
struct size_impl<filter_view_tag>
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct apply
|
||||
: result_of::distance<
|
||||
typename result_of::begin<Sequence>::type
|
||||
, typename result_of::end<Sequence>::type>
|
||||
{};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,252 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
This is an auto-generated file. Do not edit!
|
||||
==============================================================================*/
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct void_;
|
||||
namespace result_of
|
||||
{
|
||||
template <
|
||||
typename K0 = void_ , typename K1 = void_ , typename K2 = void_ , typename K3 = void_ , typename K4 = void_ , typename K5 = void_ , typename K6 = void_ , typename K7 = void_ , typename K8 = void_ , typename K9 = void_
|
||||
, typename D0 = void_ , typename D1 = void_ , typename D2 = void_ , typename D3 = void_ , typename D4 = void_ , typename D5 = void_ , typename D6 = void_ , typename D7 = void_ , typename D8 = void_ , typename D9 = void_
|
||||
, typename Extra = void_
|
||||
>
|
||||
struct make_map;
|
||||
template <>
|
||||
struct make_map<>
|
||||
{
|
||||
typedef map<> type;
|
||||
};
|
||||
}
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline map<>
|
||||
make_map()
|
||||
{
|
||||
return map<>();
|
||||
}
|
||||
namespace result_of
|
||||
{
|
||||
template <
|
||||
typename K0
|
||||
, typename D0
|
||||
>
|
||||
struct make_map<K0, D0 , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_>
|
||||
{
|
||||
typedef map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> > type;
|
||||
};
|
||||
}
|
||||
template <
|
||||
typename K0
|
||||
, typename D0
|
||||
>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> >
|
||||
make_map(D0 const& arg0)
|
||||
{
|
||||
return map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> >(
|
||||
fusion::make_pair<K0>(arg0));
|
||||
}
|
||||
namespace result_of
|
||||
{
|
||||
template <
|
||||
typename K0 , typename K1
|
||||
, typename D0 , typename D1
|
||||
>
|
||||
struct make_map<K0 , K1, D0 , D1 , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_>
|
||||
{
|
||||
typedef map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> > type;
|
||||
};
|
||||
}
|
||||
template <
|
||||
typename K0 , typename K1
|
||||
, typename D0 , typename D1
|
||||
>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> >
|
||||
make_map(D0 const& arg0 , D1 const& arg1)
|
||||
{
|
||||
return map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> >(
|
||||
fusion::make_pair<K0>(arg0) , fusion::make_pair<K1>(arg1));
|
||||
}
|
||||
namespace result_of
|
||||
{
|
||||
template <
|
||||
typename K0 , typename K1 , typename K2
|
||||
, typename D0 , typename D1 , typename D2
|
||||
>
|
||||
struct make_map<K0 , K1 , K2, D0 , D1 , D2 , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_>
|
||||
{
|
||||
typedef map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> > type;
|
||||
};
|
||||
}
|
||||
template <
|
||||
typename K0 , typename K1 , typename K2
|
||||
, typename D0 , typename D1 , typename D2
|
||||
>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> >
|
||||
make_map(D0 const& arg0 , D1 const& arg1 , D2 const& arg2)
|
||||
{
|
||||
return map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> >(
|
||||
fusion::make_pair<K0>(arg0) , fusion::make_pair<K1>(arg1) , fusion::make_pair<K2>(arg2));
|
||||
}
|
||||
namespace result_of
|
||||
{
|
||||
template <
|
||||
typename K0 , typename K1 , typename K2 , typename K3
|
||||
, typename D0 , typename D1 , typename D2 , typename D3
|
||||
>
|
||||
struct make_map<K0 , K1 , K2 , K3, D0 , D1 , D2 , D3 , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_>
|
||||
{
|
||||
typedef map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> > type;
|
||||
};
|
||||
}
|
||||
template <
|
||||
typename K0 , typename K1 , typename K2 , typename K3
|
||||
, typename D0 , typename D1 , typename D2 , typename D3
|
||||
>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> >
|
||||
make_map(D0 const& arg0 , D1 const& arg1 , D2 const& arg2 , D3 const& arg3)
|
||||
{
|
||||
return map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> >(
|
||||
fusion::make_pair<K0>(arg0) , fusion::make_pair<K1>(arg1) , fusion::make_pair<K2>(arg2) , fusion::make_pair<K3>(arg3));
|
||||
}
|
||||
namespace result_of
|
||||
{
|
||||
template <
|
||||
typename K0 , typename K1 , typename K2 , typename K3 , typename K4
|
||||
, typename D0 , typename D1 , typename D2 , typename D3 , typename D4
|
||||
>
|
||||
struct make_map<K0 , K1 , K2 , K3 , K4, D0 , D1 , D2 , D3 , D4 , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_>
|
||||
{
|
||||
typedef map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> > type;
|
||||
};
|
||||
}
|
||||
template <
|
||||
typename K0 , typename K1 , typename K2 , typename K3 , typename K4
|
||||
, typename D0 , typename D1 , typename D2 , typename D3 , typename D4
|
||||
>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> >
|
||||
make_map(D0 const& arg0 , D1 const& arg1 , D2 const& arg2 , D3 const& arg3 , D4 const& arg4)
|
||||
{
|
||||
return map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> >(
|
||||
fusion::make_pair<K0>(arg0) , fusion::make_pair<K1>(arg1) , fusion::make_pair<K2>(arg2) , fusion::make_pair<K3>(arg3) , fusion::make_pair<K4>(arg4));
|
||||
}
|
||||
namespace result_of
|
||||
{
|
||||
template <
|
||||
typename K0 , typename K1 , typename K2 , typename K3 , typename K4 , typename K5
|
||||
, typename D0 , typename D1 , typename D2 , typename D3 , typename D4 , typename D5
|
||||
>
|
||||
struct make_map<K0 , K1 , K2 , K3 , K4 , K5, D0 , D1 , D2 , D3 , D4 , D5 , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_ , void_>
|
||||
{
|
||||
typedef map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> , fusion::pair< K5 , typename detail::as_fusion_element<D5>::type> > type;
|
||||
};
|
||||
}
|
||||
template <
|
||||
typename K0 , typename K1 , typename K2 , typename K3 , typename K4 , typename K5
|
||||
, typename D0 , typename D1 , typename D2 , typename D3 , typename D4 , typename D5
|
||||
>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> , fusion::pair< K5 , typename detail::as_fusion_element<D5>::type> >
|
||||
make_map(D0 const& arg0 , D1 const& arg1 , D2 const& arg2 , D3 const& arg3 , D4 const& arg4 , D5 const& arg5)
|
||||
{
|
||||
return map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> , fusion::pair< K5 , typename detail::as_fusion_element<D5>::type> >(
|
||||
fusion::make_pair<K0>(arg0) , fusion::make_pair<K1>(arg1) , fusion::make_pair<K2>(arg2) , fusion::make_pair<K3>(arg3) , fusion::make_pair<K4>(arg4) , fusion::make_pair<K5>(arg5));
|
||||
}
|
||||
namespace result_of
|
||||
{
|
||||
template <
|
||||
typename K0 , typename K1 , typename K2 , typename K3 , typename K4 , typename K5 , typename K6
|
||||
, typename D0 , typename D1 , typename D2 , typename D3 , typename D4 , typename D5 , typename D6
|
||||
>
|
||||
struct make_map<K0 , K1 , K2 , K3 , K4 , K5 , K6, D0 , D1 , D2 , D3 , D4 , D5 , D6 , void_ , void_ , void_ , void_ , void_ , void_ , void_>
|
||||
{
|
||||
typedef map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> , fusion::pair< K5 , typename detail::as_fusion_element<D5>::type> , fusion::pair< K6 , typename detail::as_fusion_element<D6>::type> > type;
|
||||
};
|
||||
}
|
||||
template <
|
||||
typename K0 , typename K1 , typename K2 , typename K3 , typename K4 , typename K5 , typename K6
|
||||
, typename D0 , typename D1 , typename D2 , typename D3 , typename D4 , typename D5 , typename D6
|
||||
>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> , fusion::pair< K5 , typename detail::as_fusion_element<D5>::type> , fusion::pair< K6 , typename detail::as_fusion_element<D6>::type> >
|
||||
make_map(D0 const& arg0 , D1 const& arg1 , D2 const& arg2 , D3 const& arg3 , D4 const& arg4 , D5 const& arg5 , D6 const& arg6)
|
||||
{
|
||||
return map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> , fusion::pair< K5 , typename detail::as_fusion_element<D5>::type> , fusion::pair< K6 , typename detail::as_fusion_element<D6>::type> >(
|
||||
fusion::make_pair<K0>(arg0) , fusion::make_pair<K1>(arg1) , fusion::make_pair<K2>(arg2) , fusion::make_pair<K3>(arg3) , fusion::make_pair<K4>(arg4) , fusion::make_pair<K5>(arg5) , fusion::make_pair<K6>(arg6));
|
||||
}
|
||||
namespace result_of
|
||||
{
|
||||
template <
|
||||
typename K0 , typename K1 , typename K2 , typename K3 , typename K4 , typename K5 , typename K6 , typename K7
|
||||
, typename D0 , typename D1 , typename D2 , typename D3 , typename D4 , typename D5 , typename D6 , typename D7
|
||||
>
|
||||
struct make_map<K0 , K1 , K2 , K3 , K4 , K5 , K6 , K7, D0 , D1 , D2 , D3 , D4 , D5 , D6 , D7 , void_ , void_ , void_ , void_ , void_>
|
||||
{
|
||||
typedef map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> , fusion::pair< K5 , typename detail::as_fusion_element<D5>::type> , fusion::pair< K6 , typename detail::as_fusion_element<D6>::type> , fusion::pair< K7 , typename detail::as_fusion_element<D7>::type> > type;
|
||||
};
|
||||
}
|
||||
template <
|
||||
typename K0 , typename K1 , typename K2 , typename K3 , typename K4 , typename K5 , typename K6 , typename K7
|
||||
, typename D0 , typename D1 , typename D2 , typename D3 , typename D4 , typename D5 , typename D6 , typename D7
|
||||
>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> , fusion::pair< K5 , typename detail::as_fusion_element<D5>::type> , fusion::pair< K6 , typename detail::as_fusion_element<D6>::type> , fusion::pair< K7 , typename detail::as_fusion_element<D7>::type> >
|
||||
make_map(D0 const& arg0 , D1 const& arg1 , D2 const& arg2 , D3 const& arg3 , D4 const& arg4 , D5 const& arg5 , D6 const& arg6 , D7 const& arg7)
|
||||
{
|
||||
return map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> , fusion::pair< K5 , typename detail::as_fusion_element<D5>::type> , fusion::pair< K6 , typename detail::as_fusion_element<D6>::type> , fusion::pair< K7 , typename detail::as_fusion_element<D7>::type> >(
|
||||
fusion::make_pair<K0>(arg0) , fusion::make_pair<K1>(arg1) , fusion::make_pair<K2>(arg2) , fusion::make_pair<K3>(arg3) , fusion::make_pair<K4>(arg4) , fusion::make_pair<K5>(arg5) , fusion::make_pair<K6>(arg6) , fusion::make_pair<K7>(arg7));
|
||||
}
|
||||
namespace result_of
|
||||
{
|
||||
template <
|
||||
typename K0 , typename K1 , typename K2 , typename K3 , typename K4 , typename K5 , typename K6 , typename K7 , typename K8
|
||||
, typename D0 , typename D1 , typename D2 , typename D3 , typename D4 , typename D5 , typename D6 , typename D7 , typename D8
|
||||
>
|
||||
struct make_map<K0 , K1 , K2 , K3 , K4 , K5 , K6 , K7 , K8, D0 , D1 , D2 , D3 , D4 , D5 , D6 , D7 , D8 , void_ , void_ , void_>
|
||||
{
|
||||
typedef map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> , fusion::pair< K5 , typename detail::as_fusion_element<D5>::type> , fusion::pair< K6 , typename detail::as_fusion_element<D6>::type> , fusion::pair< K7 , typename detail::as_fusion_element<D7>::type> , fusion::pair< K8 , typename detail::as_fusion_element<D8>::type> > type;
|
||||
};
|
||||
}
|
||||
template <
|
||||
typename K0 , typename K1 , typename K2 , typename K3 , typename K4 , typename K5 , typename K6 , typename K7 , typename K8
|
||||
, typename D0 , typename D1 , typename D2 , typename D3 , typename D4 , typename D5 , typename D6 , typename D7 , typename D8
|
||||
>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> , fusion::pair< K5 , typename detail::as_fusion_element<D5>::type> , fusion::pair< K6 , typename detail::as_fusion_element<D6>::type> , fusion::pair< K7 , typename detail::as_fusion_element<D7>::type> , fusion::pair< K8 , typename detail::as_fusion_element<D8>::type> >
|
||||
make_map(D0 const& arg0 , D1 const& arg1 , D2 const& arg2 , D3 const& arg3 , D4 const& arg4 , D5 const& arg5 , D6 const& arg6 , D7 const& arg7 , D8 const& arg8)
|
||||
{
|
||||
return map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> , fusion::pair< K5 , typename detail::as_fusion_element<D5>::type> , fusion::pair< K6 , typename detail::as_fusion_element<D6>::type> , fusion::pair< K7 , typename detail::as_fusion_element<D7>::type> , fusion::pair< K8 , typename detail::as_fusion_element<D8>::type> >(
|
||||
fusion::make_pair<K0>(arg0) , fusion::make_pair<K1>(arg1) , fusion::make_pair<K2>(arg2) , fusion::make_pair<K3>(arg3) , fusion::make_pair<K4>(arg4) , fusion::make_pair<K5>(arg5) , fusion::make_pair<K6>(arg6) , fusion::make_pair<K7>(arg7) , fusion::make_pair<K8>(arg8));
|
||||
}
|
||||
namespace result_of
|
||||
{
|
||||
template <
|
||||
typename K0 , typename K1 , typename K2 , typename K3 , typename K4 , typename K5 , typename K6 , typename K7 , typename K8 , typename K9
|
||||
, typename D0 , typename D1 , typename D2 , typename D3 , typename D4 , typename D5 , typename D6 , typename D7 , typename D8 , typename D9
|
||||
>
|
||||
struct make_map<K0 , K1 , K2 , K3 , K4 , K5 , K6 , K7 , K8 , K9, D0 , D1 , D2 , D3 , D4 , D5 , D6 , D7 , D8 , D9 , void_>
|
||||
{
|
||||
typedef map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> , fusion::pair< K5 , typename detail::as_fusion_element<D5>::type> , fusion::pair< K6 , typename detail::as_fusion_element<D6>::type> , fusion::pair< K7 , typename detail::as_fusion_element<D7>::type> , fusion::pair< K8 , typename detail::as_fusion_element<D8>::type> , fusion::pair< K9 , typename detail::as_fusion_element<D9>::type> > type;
|
||||
};
|
||||
}
|
||||
template <
|
||||
typename K0 , typename K1 , typename K2 , typename K3 , typename K4 , typename K5 , typename K6 , typename K7 , typename K8 , typename K9
|
||||
, typename D0 , typename D1 , typename D2 , typename D3 , typename D4 , typename D5 , typename D6 , typename D7 , typename D8 , typename D9
|
||||
>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> , fusion::pair< K5 , typename detail::as_fusion_element<D5>::type> , fusion::pair< K6 , typename detail::as_fusion_element<D6>::type> , fusion::pair< K7 , typename detail::as_fusion_element<D7>::type> , fusion::pair< K8 , typename detail::as_fusion_element<D8>::type> , fusion::pair< K9 , typename detail::as_fusion_element<D9>::type> >
|
||||
make_map(D0 const& arg0 , D1 const& arg1 , D2 const& arg2 , D3 const& arg3 , D4 const& arg4 , D5 const& arg5 , D6 const& arg6 , D7 const& arg7 , D8 const& arg8 , D9 const& arg9)
|
||||
{
|
||||
return map<fusion::pair< K0 , typename detail::as_fusion_element<D0>::type> , fusion::pair< K1 , typename detail::as_fusion_element<D1>::type> , fusion::pair< K2 , typename detail::as_fusion_element<D2>::type> , fusion::pair< K3 , typename detail::as_fusion_element<D3>::type> , fusion::pair< K4 , typename detail::as_fusion_element<D4>::type> , fusion::pair< K5 , typename detail::as_fusion_element<D5>::type> , fusion::pair< K6 , typename detail::as_fusion_element<D6>::type> , fusion::pair< K7 , typename detail::as_fusion_element<D7>::type> , fusion::pair< K8 , typename detail::as_fusion_element<D8>::type> , fusion::pair< K9 , typename detail::as_fusion_element<D9>::type> >(
|
||||
fusion::make_pair<K0>(arg0) , fusion::make_pair<K1>(arg1) , fusion::make_pair<K2>(arg2) , fusion::make_pair<K3>(arg3) , fusion::make_pair<K4>(arg4) , fusion::make_pair<K5>(arg5) , fusion::make_pair<K6>(arg6) , fusion::make_pair<K7>(arg7) , fusion::make_pair<K8>(arg8) , fusion::make_pair<K9>(arg9));
|
||||
}
|
||||
}}
|
||||
@@ -0,0 +1,387 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// \file fold_impl.hpp
|
||||
/// Contains definition of fold_impl<> and reverse_fold_impl<> templates.
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct fold_impl<State0, Fun, Expr, State, Data, 1>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state0;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >::result_type state1;
|
||||
typedef state1 result_type;
|
||||
result_type operator ()(
|
||||
typename fold_impl::expr_param e
|
||||
, typename fold_impl::state_param s
|
||||
, typename fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state0 s0 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >()( proto::child_c< 0>(e) , s0 , d );
|
||||
return s1;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct reverse_fold_impl<State0, Fun, Expr, State, Data, 1>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state1;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >::result_type state0;
|
||||
typedef state0 result_type;
|
||||
result_type operator ()(
|
||||
typename reverse_fold_impl::expr_param e
|
||||
, typename reverse_fold_impl::state_param s
|
||||
, typename reverse_fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state1 s1 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state0 s0 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >()( proto::child_c<0>(e) , s1 , d );
|
||||
return s0;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct fold_impl<State0, Fun, Expr, State, Data, 2>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state0;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >::result_type state2;
|
||||
typedef state2 result_type;
|
||||
result_type operator ()(
|
||||
typename fold_impl::expr_param e
|
||||
, typename fold_impl::state_param s
|
||||
, typename fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state0 s0 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >()( proto::child_c< 0>(e) , s0 , d ); state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >()( proto::child_c< 1>(e) , s1 , d );
|
||||
return s2;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct reverse_fold_impl<State0, Fun, Expr, State, Data, 2>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state2;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >::result_type state0;
|
||||
typedef state0 result_type;
|
||||
result_type operator ()(
|
||||
typename reverse_fold_impl::expr_param e
|
||||
, typename reverse_fold_impl::state_param s
|
||||
, typename reverse_fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state2 s2 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >()( proto::child_c<1>(e) , s2 , d ); state0 s0 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >()( proto::child_c<0>(e) , s1 , d );
|
||||
return s0;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct fold_impl<State0, Fun, Expr, State, Data, 3>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state0;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >::result_type state2; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 2>::type , state2 , Data >::result_type state3;
|
||||
typedef state3 result_type;
|
||||
result_type operator ()(
|
||||
typename fold_impl::expr_param e
|
||||
, typename fold_impl::state_param s
|
||||
, typename fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state0 s0 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >()( proto::child_c< 0>(e) , s0 , d ); state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >()( proto::child_c< 1>(e) , s1 , d ); state3 s3 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 2>::type , state2 , Data >()( proto::child_c< 2>(e) , s2 , d );
|
||||
return s3;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct reverse_fold_impl<State0, Fun, Expr, State, Data, 3>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state3;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 2 >::type , state3 , Data >::result_type state2; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >::result_type state0;
|
||||
typedef state0 result_type;
|
||||
result_type operator ()(
|
||||
typename reverse_fold_impl::expr_param e
|
||||
, typename reverse_fold_impl::state_param s
|
||||
, typename reverse_fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state3 s3 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 2 >::type , state3 , Data >()( proto::child_c<2>(e) , s3 , d ); state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >()( proto::child_c<1>(e) , s2 , d ); state0 s0 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >()( proto::child_c<0>(e) , s1 , d );
|
||||
return s0;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct fold_impl<State0, Fun, Expr, State, Data, 4>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state0;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >::result_type state2; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 2>::type , state2 , Data >::result_type state3; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 3>::type , state3 , Data >::result_type state4;
|
||||
typedef state4 result_type;
|
||||
result_type operator ()(
|
||||
typename fold_impl::expr_param e
|
||||
, typename fold_impl::state_param s
|
||||
, typename fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state0 s0 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >()( proto::child_c< 0>(e) , s0 , d ); state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >()( proto::child_c< 1>(e) , s1 , d ); state3 s3 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 2>::type , state2 , Data >()( proto::child_c< 2>(e) , s2 , d ); state4 s4 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 3>::type , state3 , Data >()( proto::child_c< 3>(e) , s3 , d );
|
||||
return s4;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct reverse_fold_impl<State0, Fun, Expr, State, Data, 4>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state4;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 3 >::type , state4 , Data >::result_type state3; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 2 >::type , state3 , Data >::result_type state2; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >::result_type state0;
|
||||
typedef state0 result_type;
|
||||
result_type operator ()(
|
||||
typename reverse_fold_impl::expr_param e
|
||||
, typename reverse_fold_impl::state_param s
|
||||
, typename reverse_fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state4 s4 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state3 s3 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 3 >::type , state4 , Data >()( proto::child_c<3>(e) , s4 , d ); state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 2 >::type , state3 , Data >()( proto::child_c<2>(e) , s3 , d ); state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >()( proto::child_c<1>(e) , s2 , d ); state0 s0 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >()( proto::child_c<0>(e) , s1 , d );
|
||||
return s0;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct fold_impl<State0, Fun, Expr, State, Data, 5>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state0;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >::result_type state2; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 2>::type , state2 , Data >::result_type state3; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 3>::type , state3 , Data >::result_type state4; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 4>::type , state4 , Data >::result_type state5;
|
||||
typedef state5 result_type;
|
||||
result_type operator ()(
|
||||
typename fold_impl::expr_param e
|
||||
, typename fold_impl::state_param s
|
||||
, typename fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state0 s0 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >()( proto::child_c< 0>(e) , s0 , d ); state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >()( proto::child_c< 1>(e) , s1 , d ); state3 s3 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 2>::type , state2 , Data >()( proto::child_c< 2>(e) , s2 , d ); state4 s4 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 3>::type , state3 , Data >()( proto::child_c< 3>(e) , s3 , d ); state5 s5 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 4>::type , state4 , Data >()( proto::child_c< 4>(e) , s4 , d );
|
||||
return s5;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct reverse_fold_impl<State0, Fun, Expr, State, Data, 5>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state5;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 4 >::type , state5 , Data >::result_type state4; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 3 >::type , state4 , Data >::result_type state3; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 2 >::type , state3 , Data >::result_type state2; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >::result_type state0;
|
||||
typedef state0 result_type;
|
||||
result_type operator ()(
|
||||
typename reverse_fold_impl::expr_param e
|
||||
, typename reverse_fold_impl::state_param s
|
||||
, typename reverse_fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state5 s5 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state4 s4 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 4 >::type , state5 , Data >()( proto::child_c<4>(e) , s5 , d ); state3 s3 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 3 >::type , state4 , Data >()( proto::child_c<3>(e) , s4 , d ); state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 2 >::type , state3 , Data >()( proto::child_c<2>(e) , s3 , d ); state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >()( proto::child_c<1>(e) , s2 , d ); state0 s0 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >()( proto::child_c<0>(e) , s1 , d );
|
||||
return s0;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct fold_impl<State0, Fun, Expr, State, Data, 6>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state0;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >::result_type state2; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 2>::type , state2 , Data >::result_type state3; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 3>::type , state3 , Data >::result_type state4; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 4>::type , state4 , Data >::result_type state5; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 5>::type , state5 , Data >::result_type state6;
|
||||
typedef state6 result_type;
|
||||
result_type operator ()(
|
||||
typename fold_impl::expr_param e
|
||||
, typename fold_impl::state_param s
|
||||
, typename fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state0 s0 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >()( proto::child_c< 0>(e) , s0 , d ); state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >()( proto::child_c< 1>(e) , s1 , d ); state3 s3 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 2>::type , state2 , Data >()( proto::child_c< 2>(e) , s2 , d ); state4 s4 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 3>::type , state3 , Data >()( proto::child_c< 3>(e) , s3 , d ); state5 s5 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 4>::type , state4 , Data >()( proto::child_c< 4>(e) , s4 , d ); state6 s6 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 5>::type , state5 , Data >()( proto::child_c< 5>(e) , s5 , d );
|
||||
return s6;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct reverse_fold_impl<State0, Fun, Expr, State, Data, 6>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state6;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 5 >::type , state6 , Data >::result_type state5; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 4 >::type , state5 , Data >::result_type state4; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 3 >::type , state4 , Data >::result_type state3; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 2 >::type , state3 , Data >::result_type state2; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >::result_type state0;
|
||||
typedef state0 result_type;
|
||||
result_type operator ()(
|
||||
typename reverse_fold_impl::expr_param e
|
||||
, typename reverse_fold_impl::state_param s
|
||||
, typename reverse_fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state6 s6 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state5 s5 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 5 >::type , state6 , Data >()( proto::child_c<5>(e) , s6 , d ); state4 s4 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 4 >::type , state5 , Data >()( proto::child_c<4>(e) , s5 , d ); state3 s3 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 3 >::type , state4 , Data >()( proto::child_c<3>(e) , s4 , d ); state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 2 >::type , state3 , Data >()( proto::child_c<2>(e) , s3 , d ); state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >()( proto::child_c<1>(e) , s2 , d ); state0 s0 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >()( proto::child_c<0>(e) , s1 , d );
|
||||
return s0;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct fold_impl<State0, Fun, Expr, State, Data, 7>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state0;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >::result_type state2; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 2>::type , state2 , Data >::result_type state3; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 3>::type , state3 , Data >::result_type state4; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 4>::type , state4 , Data >::result_type state5; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 5>::type , state5 , Data >::result_type state6; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 6>::type , state6 , Data >::result_type state7;
|
||||
typedef state7 result_type;
|
||||
result_type operator ()(
|
||||
typename fold_impl::expr_param e
|
||||
, typename fold_impl::state_param s
|
||||
, typename fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state0 s0 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >()( proto::child_c< 0>(e) , s0 , d ); state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >()( proto::child_c< 1>(e) , s1 , d ); state3 s3 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 2>::type , state2 , Data >()( proto::child_c< 2>(e) , s2 , d ); state4 s4 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 3>::type , state3 , Data >()( proto::child_c< 3>(e) , s3 , d ); state5 s5 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 4>::type , state4 , Data >()( proto::child_c< 4>(e) , s4 , d ); state6 s6 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 5>::type , state5 , Data >()( proto::child_c< 5>(e) , s5 , d ); state7 s7 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 6>::type , state6 , Data >()( proto::child_c< 6>(e) , s6 , d );
|
||||
return s7;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct reverse_fold_impl<State0, Fun, Expr, State, Data, 7>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state7;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 6 >::type , state7 , Data >::result_type state6; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 5 >::type , state6 , Data >::result_type state5; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 4 >::type , state5 , Data >::result_type state4; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 3 >::type , state4 , Data >::result_type state3; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 2 >::type , state3 , Data >::result_type state2; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >::result_type state0;
|
||||
typedef state0 result_type;
|
||||
result_type operator ()(
|
||||
typename reverse_fold_impl::expr_param e
|
||||
, typename reverse_fold_impl::state_param s
|
||||
, typename reverse_fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state7 s7 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state6 s6 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 6 >::type , state7 , Data >()( proto::child_c<6>(e) , s7 , d ); state5 s5 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 5 >::type , state6 , Data >()( proto::child_c<5>(e) , s6 , d ); state4 s4 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 4 >::type , state5 , Data >()( proto::child_c<4>(e) , s5 , d ); state3 s3 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 3 >::type , state4 , Data >()( proto::child_c<3>(e) , s4 , d ); state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 2 >::type , state3 , Data >()( proto::child_c<2>(e) , s3 , d ); state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >()( proto::child_c<1>(e) , s2 , d ); state0 s0 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >()( proto::child_c<0>(e) , s1 , d );
|
||||
return s0;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct fold_impl<State0, Fun, Expr, State, Data, 8>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state0;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >::result_type state2; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 2>::type , state2 , Data >::result_type state3; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 3>::type , state3 , Data >::result_type state4; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 4>::type , state4 , Data >::result_type state5; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 5>::type , state5 , Data >::result_type state6; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 6>::type , state6 , Data >::result_type state7; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 7>::type , state7 , Data >::result_type state8;
|
||||
typedef state8 result_type;
|
||||
result_type operator ()(
|
||||
typename fold_impl::expr_param e
|
||||
, typename fold_impl::state_param s
|
||||
, typename fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state0 s0 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >()( proto::child_c< 0>(e) , s0 , d ); state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >()( proto::child_c< 1>(e) , s1 , d ); state3 s3 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 2>::type , state2 , Data >()( proto::child_c< 2>(e) , s2 , d ); state4 s4 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 3>::type , state3 , Data >()( proto::child_c< 3>(e) , s3 , d ); state5 s5 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 4>::type , state4 , Data >()( proto::child_c< 4>(e) , s4 , d ); state6 s6 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 5>::type , state5 , Data >()( proto::child_c< 5>(e) , s5 , d ); state7 s7 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 6>::type , state6 , Data >()( proto::child_c< 6>(e) , s6 , d ); state8 s8 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 7>::type , state7 , Data >()( proto::child_c< 7>(e) , s7 , d );
|
||||
return s8;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct reverse_fold_impl<State0, Fun, Expr, State, Data, 8>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state8;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 7 >::type , state8 , Data >::result_type state7; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 6 >::type , state7 , Data >::result_type state6; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 5 >::type , state6 , Data >::result_type state5; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 4 >::type , state5 , Data >::result_type state4; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 3 >::type , state4 , Data >::result_type state3; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 2 >::type , state3 , Data >::result_type state2; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >::result_type state0;
|
||||
typedef state0 result_type;
|
||||
result_type operator ()(
|
||||
typename reverse_fold_impl::expr_param e
|
||||
, typename reverse_fold_impl::state_param s
|
||||
, typename reverse_fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state8 s8 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state7 s7 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 7 >::type , state8 , Data >()( proto::child_c<7>(e) , s8 , d ); state6 s6 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 6 >::type , state7 , Data >()( proto::child_c<6>(e) , s7 , d ); state5 s5 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 5 >::type , state6 , Data >()( proto::child_c<5>(e) , s6 , d ); state4 s4 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 4 >::type , state5 , Data >()( proto::child_c<4>(e) , s5 , d ); state3 s3 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 3 >::type , state4 , Data >()( proto::child_c<3>(e) , s4 , d ); state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 2 >::type , state3 , Data >()( proto::child_c<2>(e) , s3 , d ); state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >()( proto::child_c<1>(e) , s2 , d ); state0 s0 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >()( proto::child_c<0>(e) , s1 , d );
|
||||
return s0;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct fold_impl<State0, Fun, Expr, State, Data, 9>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state0;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >::result_type state2; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 2>::type , state2 , Data >::result_type state3; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 3>::type , state3 , Data >::result_type state4; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 4>::type , state4 , Data >::result_type state5; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 5>::type , state5 , Data >::result_type state6; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 6>::type , state6 , Data >::result_type state7; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 7>::type , state7 , Data >::result_type state8; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 8>::type , state8 , Data >::result_type state9;
|
||||
typedef state9 result_type;
|
||||
result_type operator ()(
|
||||
typename fold_impl::expr_param e
|
||||
, typename fold_impl::state_param s
|
||||
, typename fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state0 s0 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >()( proto::child_c< 0>(e) , s0 , d ); state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >()( proto::child_c< 1>(e) , s1 , d ); state3 s3 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 2>::type , state2 , Data >()( proto::child_c< 2>(e) , s2 , d ); state4 s4 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 3>::type , state3 , Data >()( proto::child_c< 3>(e) , s3 , d ); state5 s5 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 4>::type , state4 , Data >()( proto::child_c< 4>(e) , s4 , d ); state6 s6 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 5>::type , state5 , Data >()( proto::child_c< 5>(e) , s5 , d ); state7 s7 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 6>::type , state6 , Data >()( proto::child_c< 6>(e) , s6 , d ); state8 s8 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 7>::type , state7 , Data >()( proto::child_c< 7>(e) , s7 , d ); state9 s9 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 8>::type , state8 , Data >()( proto::child_c< 8>(e) , s8 , d );
|
||||
return s9;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct reverse_fold_impl<State0, Fun, Expr, State, Data, 9>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state9;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 8 >::type , state9 , Data >::result_type state8; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 7 >::type , state8 , Data >::result_type state7; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 6 >::type , state7 , Data >::result_type state6; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 5 >::type , state6 , Data >::result_type state5; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 4 >::type , state5 , Data >::result_type state4; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 3 >::type , state4 , Data >::result_type state3; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 2 >::type , state3 , Data >::result_type state2; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >::result_type state0;
|
||||
typedef state0 result_type;
|
||||
result_type operator ()(
|
||||
typename reverse_fold_impl::expr_param e
|
||||
, typename reverse_fold_impl::state_param s
|
||||
, typename reverse_fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state9 s9 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state8 s8 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 8 >::type , state9 , Data >()( proto::child_c<8>(e) , s9 , d ); state7 s7 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 7 >::type , state8 , Data >()( proto::child_c<7>(e) , s8 , d ); state6 s6 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 6 >::type , state7 , Data >()( proto::child_c<6>(e) , s7 , d ); state5 s5 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 5 >::type , state6 , Data >()( proto::child_c<5>(e) , s6 , d ); state4 s4 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 4 >::type , state5 , Data >()( proto::child_c<4>(e) , s5 , d ); state3 s3 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 3 >::type , state4 , Data >()( proto::child_c<3>(e) , s4 , d ); state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 2 >::type , state3 , Data >()( proto::child_c<2>(e) , s3 , d ); state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >()( proto::child_c<1>(e) , s2 , d ); state0 s0 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >()( proto::child_c<0>(e) , s1 , d );
|
||||
return s0;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct fold_impl<State0, Fun, Expr, State, Data, 10>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state0;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >::result_type state2; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 2>::type , state2 , Data >::result_type state3; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 3>::type , state3 , Data >::result_type state4; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 4>::type , state4 , Data >::result_type state5; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 5>::type , state5 , Data >::result_type state6; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 6>::type , state6 , Data >::result_type state7; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 7>::type , state7 , Data >::result_type state8; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 8>::type , state8 , Data >::result_type state9; typedef typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 9>::type , state9 , Data >::result_type state10;
|
||||
typedef state10 result_type;
|
||||
result_type operator ()(
|
||||
typename fold_impl::expr_param e
|
||||
, typename fold_impl::state_param s
|
||||
, typename fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state0 s0 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 0>::type , state0 , Data >()( proto::child_c< 0>(e) , s0 , d ); state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 1>::type , state1 , Data >()( proto::child_c< 1>(e) , s1 , d ); state3 s3 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 2>::type , state2 , Data >()( proto::child_c< 2>(e) , s2 , d ); state4 s4 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 3>::type , state3 , Data >()( proto::child_c< 3>(e) , s3 , d ); state5 s5 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 4>::type , state4 , Data >()( proto::child_c< 4>(e) , s4 , d ); state6 s6 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 5>::type , state5 , Data >()( proto::child_c< 5>(e) , s5 , d ); state7 s7 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 6>::type , state6 , Data >()( proto::child_c< 6>(e) , s6 , d ); state8 s8 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 7>::type , state7 , Data >()( proto::child_c< 7>(e) , s7 , d ); state9 s9 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 8>::type , state8 , Data >()( proto::child_c< 8>(e) , s8 , d ); state10 s10 = typename when<_, Fun>::template impl< typename result_of::child_c<Expr, 9>::type , state9 , Data >()( proto::child_c< 9>(e) , s9 , d );
|
||||
return s10;
|
||||
}
|
||||
};
|
||||
template<typename State0, typename Fun, typename Expr, typename State, typename Data>
|
||||
struct reverse_fold_impl<State0, Fun, Expr, State, Data, 10>
|
||||
: transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename when<_, State0>::template impl<Expr, State, Data>::result_type state10;
|
||||
typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 9 >::type , state10 , Data >::result_type state9; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 8 >::type , state9 , Data >::result_type state8; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 7 >::type , state8 , Data >::result_type state7; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 6 >::type , state7 , Data >::result_type state6; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 5 >::type , state6 , Data >::result_type state5; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 4 >::type , state5 , Data >::result_type state4; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 3 >::type , state4 , Data >::result_type state3; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 2 >::type , state3 , Data >::result_type state2; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >::result_type state1; typedef typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >::result_type state0;
|
||||
typedef state0 result_type;
|
||||
result_type operator ()(
|
||||
typename reverse_fold_impl::expr_param e
|
||||
, typename reverse_fold_impl::state_param s
|
||||
, typename reverse_fold_impl::data_param d
|
||||
) const
|
||||
{
|
||||
state10 s10 =
|
||||
typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
|
||||
state9 s9 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 9 >::type , state10 , Data >()( proto::child_c<9>(e) , s10 , d ); state8 s8 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 8 >::type , state9 , Data >()( proto::child_c<8>(e) , s9 , d ); state7 s7 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 7 >::type , state8 , Data >()( proto::child_c<7>(e) , s8 , d ); state6 s6 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 6 >::type , state7 , Data >()( proto::child_c<6>(e) , s7 , d ); state5 s5 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 5 >::type , state6 , Data >()( proto::child_c<5>(e) , s6 , d ); state4 s4 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 4 >::type , state5 , Data >()( proto::child_c<4>(e) , s5 , d ); state3 s3 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 3 >::type , state4 , Data >()( proto::child_c<3>(e) , s4 , d ); state2 s2 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 2 >::type , state3 , Data >()( proto::child_c<2>(e) , s3 , d ); state1 s1 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 1 >::type , state2 , Data >()( proto::child_c<1>(e) , s2 , d ); state0 s0 = typename when<_, Fun>::template impl< typename result_of::child_c< Expr , 0 >::type , state1 , Data >()( proto::child_c<0>(e) , s1 , d );
|
||||
return s0;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,146 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// Preprocessed version of "boost/mpl/times.hpp" header
|
||||
// -- DO NOT modify by hand!
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<
|
||||
typename Tag1
|
||||
, typename Tag2
|
||||
>
|
||||
struct times_impl
|
||||
: if_c<
|
||||
( BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag1)
|
||||
> BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag2)
|
||||
)
|
||||
|
||||
, aux::cast2nd_impl< times_impl< Tag1,Tag1 >,Tag1, Tag2 >
|
||||
, aux::cast1st_impl< times_impl< Tag2,Tag2 >,Tag1, Tag2 >
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
/// for Digital Mars C++/compilers with no CTPS/TTP support
|
||||
template<> struct times_impl< na,na >
|
||||
{
|
||||
template< typename U1, typename U2 > struct apply
|
||||
{
|
||||
typedef apply type;
|
||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||
};
|
||||
};
|
||||
|
||||
template< typename Tag > struct times_impl< na,Tag >
|
||||
{
|
||||
template< typename U1, typename U2 > struct apply
|
||||
{
|
||||
typedef apply type;
|
||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||
};
|
||||
};
|
||||
|
||||
template< typename Tag > struct times_impl< Tag,na >
|
||||
{
|
||||
template< typename U1, typename U2 > struct apply
|
||||
{
|
||||
typedef apply type;
|
||||
BOOST_STATIC_CONSTANT(int, value = 0);
|
||||
};
|
||||
};
|
||||
|
||||
template< typename T > struct times_tag
|
||||
{
|
||||
typedef typename T::tag type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_NA_PARAM(N1)
|
||||
, typename BOOST_MPL_AUX_NA_PARAM(N2)
|
||||
, typename N3 = na, typename N4 = na, typename N5 = na
|
||||
>
|
||||
struct times
|
||||
: times< times< times< times< N1,N2 >, N3>, N4>, N5>
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(
|
||||
5
|
||||
, times
|
||||
, ( N1, N2, N3, N4, N5 )
|
||||
)
|
||||
};
|
||||
|
||||
template<
|
||||
typename N1, typename N2, typename N3, typename N4
|
||||
>
|
||||
struct times< N1,N2,N3,N4,na >
|
||||
|
||||
: times< times< times< N1,N2 >, N3>, N4>
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(
|
||||
5
|
||||
, times
|
||||
, ( N1, N2, N3, N4, na )
|
||||
)
|
||||
};
|
||||
|
||||
template<
|
||||
typename N1, typename N2, typename N3
|
||||
>
|
||||
struct times< N1,N2,N3,na,na >
|
||||
|
||||
: times< times< N1,N2 >, N3>
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(
|
||||
5
|
||||
, times
|
||||
, ( N1, N2, N3, na, na )
|
||||
)
|
||||
};
|
||||
|
||||
template<
|
||||
typename N1, typename N2
|
||||
>
|
||||
struct times< N1,N2,na,na,na >
|
||||
: times_impl<
|
||||
typename times_tag<N1>::type
|
||||
, typename times_tag<N2>::type
|
||||
>::template apply< N1,N2 >::type
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(
|
||||
5
|
||||
, times
|
||||
, ( N1, N2, na, na, na )
|
||||
)
|
||||
|
||||
};
|
||||
|
||||
BOOST_MPL_AUX_NA_SPEC2(2, 5, times)
|
||||
|
||||
}}
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
template<>
|
||||
struct times_impl< integral_c_tag,integral_c_tag >
|
||||
{
|
||||
template< typename N1, typename N2 > struct apply
|
||||
|
||||
: integral_c<
|
||||
typename aux::largest_int<
|
||||
typename N1::value_type
|
||||
, typename N2::value_type
|
||||
>::type
|
||||
, ( BOOST_MPL_AUX_VALUE_WKND(N1)::value
|
||||
* BOOST_MPL_AUX_VALUE_WKND(N2)::value
|
||||
)
|
||||
>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
}}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
Copyright Rene Rivera 2008-2015
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
#ifndef BOOST_PREDEF_OS_UNIX_H
|
||||
#define BOOST_PREDEF_OS_UNIX_H
|
||||
|
||||
#include <boost/predef/version_number.h>
|
||||
#include <boost/predef/make.h>
|
||||
|
||||
/*`
|
||||
[heading `BOOST_OS_UNIX`]
|
||||
|
||||
[@http://en.wikipedia.org/wiki/Unix Unix Environment] operating system.
|
||||
|
||||
[table
|
||||
[[__predef_symbol__] [__predef_version__]]
|
||||
|
||||
[[`unix`] [__predef_detection__]]
|
||||
[[`__unix`] [__predef_detection__]]
|
||||
[[`_XOPEN_SOURCE`] [__predef_detection__]]
|
||||
[[`_POSIX_SOURCE`] [__predef_detection__]]
|
||||
]
|
||||
*/
|
||||
|
||||
#define BOOST_OS_UNIX BOOST_VERSION_NUMBER_NOT_AVAILABLE
|
||||
|
||||
#if defined(unix) || defined(__unix) || \
|
||||
defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE)
|
||||
# undef BOOST_OS_UNIX
|
||||
# define BOOST_OS_UNIX BOOST_VERSION_NUMBER_AVAILABLE
|
||||
#endif
|
||||
|
||||
#if BOOST_OS_UNIX
|
||||
# define BOOST_OS_UNIX_AVAILABLE
|
||||
#endif
|
||||
|
||||
#define BOOST_OS_UNIX_NAME "Unix Environment"
|
||||
|
||||
/*`
|
||||
[heading `BOOST_OS_SVR4`]
|
||||
|
||||
[@http://en.wikipedia.org/wiki/UNIX_System_V SVR4 Environment] operating system.
|
||||
|
||||
[table
|
||||
[[__predef_symbol__] [__predef_version__]]
|
||||
|
||||
[[`__sysv__`] [__predef_detection__]]
|
||||
[[`__SVR4`] [__predef_detection__]]
|
||||
[[`__svr4__`] [__predef_detection__]]
|
||||
[[`_SYSTYPE_SVR4`] [__predef_detection__]]
|
||||
]
|
||||
*/
|
||||
|
||||
#define BOOST_OS_SVR4 BOOST_VERSION_NUMBER_NOT_AVAILABLE
|
||||
|
||||
#if defined(__sysv__) || defined(__SVR4) || \
|
||||
defined(__svr4__) || defined(_SYSTYPE_SVR4)
|
||||
# undef BOOST_OS_SVR4
|
||||
# define BOOST_OS_SVR4 BOOST_VERSION_NUMBER_AVAILABLE
|
||||
#endif
|
||||
|
||||
#if BOOST_OS_SVR4
|
||||
# define BOOST_OS_SVR4_AVAILABLE
|
||||
#endif
|
||||
|
||||
#define BOOST_OS_SVR4_NAME "SVR4 Environment"
|
||||
|
||||
#endif
|
||||
|
||||
#include <boost/predef/detail/test.h>
|
||||
BOOST_PREDEF_DECLARE_TEST(BOOST_OS_UNIX,BOOST_OS_UNIX_NAME)
|
||||
BOOST_PREDEF_DECLARE_TEST(BOOST_OS_SVR4,BOOST_OS_SVR4_NAME)
|
||||
@@ -0,0 +1,96 @@
|
||||
/* boost random/generate_canonical.hpp header file
|
||||
*
|
||||
* Copyright Steven Watanabe 2011
|
||||
* Distributed under the Boost Software License, Version 1.0. (See
|
||||
* accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* See http://www.boost.org for most recent version including documentation.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BOOST_RANDOM_GENERATE_CANONICAL_HPP
|
||||
#define BOOST_RANDOM_GENERATE_CANONICAL_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config/no_tr1/cmath.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/random/detail/signed_unsigned_tools.hpp>
|
||||
#include <boost/random/detail/generator_bits.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace random {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class RealType, std::size_t bits, class URNG>
|
||||
RealType generate_canonical_impl(URNG& g, boost::mpl::true_ /*is_integral*/)
|
||||
{
|
||||
using std::pow;
|
||||
typedef typename URNG::result_type base_result;
|
||||
std::size_t digits = std::numeric_limits<RealType>::digits;
|
||||
RealType R = RealType((g.max)()) - RealType((g.min)()) + 1;
|
||||
RealType mult = R;
|
||||
RealType limit =
|
||||
pow(RealType(2),
|
||||
RealType((std::min)(static_cast<std::size_t>(bits), digits)));
|
||||
RealType S = RealType(detail::subtract<base_result>()(g(), (g.min)()));
|
||||
while(mult < limit) {
|
||||
RealType inc = RealType(detail::subtract<base_result>()(g(), (g.min)()));
|
||||
S += inc * mult;
|
||||
mult *= R;
|
||||
}
|
||||
return S / mult;
|
||||
}
|
||||
|
||||
template<class RealType, std::size_t bits, class URNG>
|
||||
RealType generate_canonical_impl(URNG& g, boost::mpl::false_ /*is_integral*/)
|
||||
{
|
||||
using std::pow;
|
||||
using std::floor;
|
||||
BOOST_ASSERT((g.min)() == 0);
|
||||
BOOST_ASSERT((g.max)() == 1);
|
||||
std::size_t digits = std::numeric_limits<RealType>::digits;
|
||||
std::size_t engine_bits = detail::generator_bits<URNG>::value();
|
||||
std::size_t b = (std::min)(bits, digits);
|
||||
RealType R = pow(RealType(2), RealType(engine_bits));
|
||||
RealType mult = R;
|
||||
RealType limit = pow(RealType(2), RealType(b));
|
||||
RealType S = RealType(g() - (g.min)());
|
||||
while(mult < limit) {
|
||||
RealType inc(floor((RealType(g()) - RealType((g.min)())) * R));
|
||||
S += inc * mult;
|
||||
mult *= R;
|
||||
}
|
||||
return S / mult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value uniformly distributed in the range [0, 1)
|
||||
* with at least @c bits random bits.
|
||||
*/
|
||||
template<class RealType, std::size_t bits, class URNG>
|
||||
RealType generate_canonical(URNG& g)
|
||||
{
|
||||
RealType result = detail::generate_canonical_impl<RealType, bits>(
|
||||
g, boost::random::traits::is_integral<typename URNG::result_type>());
|
||||
BOOST_ASSERT(result >= 0);
|
||||
BOOST_ASSERT(result <= 1);
|
||||
if(result == 1) {
|
||||
result -= std::numeric_limits<RealType>::epsilon() / 2;
|
||||
BOOST_ASSERT(result != 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace random
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_RANDOM_GENERATE_CANONICAL_HPP
|
||||
@@ -0,0 +1,101 @@
|
||||
// boost/chrono/utility/manip_base.hpp ------------------------------------------------------------//
|
||||
|
||||
// Copyright 2011 Vicente J. Botet Escriba
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/chrono for documentation.
|
||||
|
||||
#ifndef BOOST_CHRONO_UTILITY_MANIP_BASE_PTR_HPP
|
||||
#define BOOST_CHRONO_UTILITY_MANIP_BASE_PTR_HPP
|
||||
|
||||
#include <ios>
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
*/
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace chrono
|
||||
{
|
||||
|
||||
/**
|
||||
* manip is a manipulator mixin class following the CRTP.
|
||||
* @tparam Final the derived from manip and final type
|
||||
*
|
||||
* @Example
|
||||
* @code
|
||||
|
||||
class mendl: public manip<mendl>
|
||||
{
|
||||
public:
|
||||
explicit mendl(size_t how_many) :
|
||||
count(how_many) {}
|
||||
template <typename out_stream>
|
||||
void operator()(out_stream &out) const
|
||||
{
|
||||
for (size_t line = 0; line < count; ++line)
|
||||
{
|
||||
out.put(out.widen('\n'));
|
||||
}
|
||||
out.flush();
|
||||
}
|
||||
private:
|
||||
size_t count;
|
||||
};
|
||||
|
||||
* @codeend
|
||||
*/
|
||||
template <typename Final>
|
||||
class manip
|
||||
{
|
||||
public:
|
||||
/**
|
||||
*
|
||||
* @param ios the io stream or ios_base.
|
||||
* @Effects calls to the manipulator final functor.
|
||||
*/
|
||||
//template <typename out_stream>
|
||||
void operator()(std::ios_base &ios) const
|
||||
{
|
||||
(*static_cast<const Final *> (this))(ios);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @c manip stream inserter
|
||||
* @param out the io stream or ios_base.
|
||||
* @param op the manipulator instance.
|
||||
* @Effects if @c out is good calls to the manipulator functor @op.
|
||||
* @return @c out
|
||||
*/
|
||||
template <typename out_stream, typename manip_type>
|
||||
out_stream &operator<<(out_stream &out, const manip<manip_type> &op)
|
||||
{
|
||||
if (out.good())
|
||||
op(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @c manip stream extractor
|
||||
* @param in the io stream or ios_base.
|
||||
* @param op the manipulator instance.
|
||||
* @Effects if @c in is good calls to the manipulator functor @op.
|
||||
* @return @c in
|
||||
*/
|
||||
template <typename in_stream, typename manip_type>
|
||||
in_stream &operator>>(in_stream &in, const manip<manip_type> &op)
|
||||
{
|
||||
if (in.good())
|
||||
op(in);
|
||||
return in;
|
||||
}
|
||||
|
||||
} // namespace chrono
|
||||
} // namespace boost
|
||||
|
||||
#endif // header
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
// Copyright Aleksey Gurtovoy 2000-2004
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
// *Preprocessed* version of the main "bind_fwd.hpp" header
|
||||
// -- DO NOT modify by hand!
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<
|
||||
typename F
|
||||
>
|
||||
struct bind0;
|
||||
|
||||
template<
|
||||
typename F, typename T1
|
||||
>
|
||||
struct bind1;
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2
|
||||
>
|
||||
struct bind2;
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2, typename T3
|
||||
>
|
||||
struct bind3;
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2, typename T3, typename T4
|
||||
>
|
||||
struct bind4;
|
||||
|
||||
template<
|
||||
typename F, typename T1, typename T2, typename T3, typename T4
|
||||
, typename T5
|
||||
>
|
||||
struct bind5;
|
||||
|
||||
}}
|
||||
|
||||
@@ -0,0 +1,295 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision$
|
||||
//
|
||||
// Description : main function implementation for Unit Test Framework
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_UNIT_TEST_MAIN_IPP_012205GER
|
||||
#define BOOST_TEST_UNIT_TEST_MAIN_IPP_012205GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/framework.hpp>
|
||||
#include <boost/test/results_collector.hpp>
|
||||
#include <boost/test/results_reporter.hpp>
|
||||
|
||||
#include <boost/test/tree/visitor.hpp>
|
||||
#include <boost/test/tree/test_unit.hpp>
|
||||
#include <boost/test/tree/traverse.hpp>
|
||||
|
||||
#include <boost/test/unit_test_parameters.hpp>
|
||||
|
||||
#include <boost/test/utils/foreach.hpp>
|
||||
#include <boost/test/utils/basic_cstring/io.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/cstdlib.hpp>
|
||||
|
||||
// STL
|
||||
#include <cstdio>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <set>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace unit_test {
|
||||
|
||||
namespace ut_detail {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** hrf_content_reporter ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
struct hrf_content_reporter : test_tree_visitor {
|
||||
explicit hrf_content_reporter( std::ostream& os ) : m_os( os ), m_indent( -4 ) {} // skip master test suite
|
||||
|
||||
private:
|
||||
void report_test_unit( test_unit const& tu )
|
||||
{
|
||||
m_os << std::setw( m_indent ) << "" << tu.p_name;
|
||||
m_os << (tu.p_default_status == test_unit::RS_ENABLED ? "*" : " ");
|
||||
//m_os << '[' << tu.p_sibling_rank << ']';
|
||||
if( !tu.p_description->empty() )
|
||||
m_os << ": " << tu.p_description;
|
||||
|
||||
m_os << "\n";
|
||||
}
|
||||
virtual void visit( test_case const& tc ) { report_test_unit( tc ); }
|
||||
virtual bool test_suite_start( test_suite const& ts )
|
||||
{
|
||||
if( m_indent >= 0 )
|
||||
report_test_unit( ts );
|
||||
m_indent += 4;
|
||||
return true;
|
||||
}
|
||||
virtual void test_suite_finish( test_suite const& )
|
||||
{
|
||||
m_indent -= 4;
|
||||
}
|
||||
|
||||
// Data members
|
||||
std::ostream& m_os;
|
||||
int m_indent;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** dot_content_reporter ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
struct dot_content_reporter : test_tree_visitor {
|
||||
explicit dot_content_reporter( std::ostream& os ) : m_os( os ) {}
|
||||
|
||||
private:
|
||||
void report_test_unit( test_unit const& tu )
|
||||
{
|
||||
bool master_ts = tu.p_parent_id == INV_TEST_UNIT_ID;
|
||||
|
||||
m_os << "tu" << tu.p_id;
|
||||
|
||||
m_os << (master_ts ? "[shape=ellipse,peripheries=2" : "[shape=Mrecord" );
|
||||
|
||||
m_os << ",fontname=Helvetica";
|
||||
|
||||
m_os << (tu.p_default_status == test_unit::RS_ENABLED ? ",color=green" : ",color=yellow");
|
||||
|
||||
if( master_ts )
|
||||
m_os << ",label=\"" << tu.p_name << "\"];\n";
|
||||
else {
|
||||
m_os << ",label=\"" << tu.p_name << "|" << tu.p_file_name << "(" << tu.p_line_num << ")";
|
||||
if( tu.p_timeout > 0 )
|
||||
m_os << "|timeout=" << tu.p_timeout;
|
||||
if( tu.p_expected_failures != 0 )
|
||||
m_os << "|expected failures=" << tu.p_expected_failures;
|
||||
if( !tu.p_labels->empty() ) {
|
||||
m_os << "|labels:";
|
||||
|
||||
BOOST_TEST_FOREACH( std::string const&, l, tu.p_labels.get() )
|
||||
m_os << " @" << l;
|
||||
}
|
||||
m_os << "\"];\n";
|
||||
}
|
||||
|
||||
if( !master_ts )
|
||||
m_os << "tu" << tu.p_parent_id << " -> " << "tu" << tu.p_id << ";\n";
|
||||
|
||||
BOOST_TEST_FOREACH( test_unit_id, dep_id, tu.p_dependencies.get() ) {
|
||||
test_unit const& dep = framework::get( dep_id, TUT_ANY );
|
||||
|
||||
m_os << "tu" << tu.p_id << " -> " << "tu" << dep.p_id << "[color=red,style=dotted,constraint=false];\n";
|
||||
}
|
||||
|
||||
}
|
||||
virtual void visit( test_case const& tc )
|
||||
{
|
||||
report_test_unit( tc );
|
||||
}
|
||||
virtual bool test_suite_start( test_suite const& ts )
|
||||
{
|
||||
if( ts.p_parent_id == INV_TEST_UNIT_ID )
|
||||
m_os << "digraph G {rankdir=LR;\n";
|
||||
|
||||
report_test_unit( ts );
|
||||
|
||||
m_os << "{\n";
|
||||
|
||||
return true;
|
||||
}
|
||||
virtual void test_suite_finish( test_suite const& ts )
|
||||
{
|
||||
m_os << "}\n";
|
||||
if( ts.p_parent_id == INV_TEST_UNIT_ID )
|
||||
m_os << "}\n";
|
||||
}
|
||||
|
||||
std::ostream& m_os;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** labels_collector ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
struct labels_collector : test_tree_visitor {
|
||||
std::set<std::string> const& labels() const { return m_labels; }
|
||||
|
||||
private:
|
||||
virtual bool visit( test_unit const& tu )
|
||||
{
|
||||
m_labels.insert( tu.p_labels->begin(), tu.p_labels->end() );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Data members
|
||||
std::set<std::string> m_labels;
|
||||
};
|
||||
|
||||
} // namespace ut_detail
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** unit_test_main ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
int BOOST_TEST_DECL
|
||||
unit_test_main( init_unit_test_func init_func, int argc, char* argv[] )
|
||||
{
|
||||
int result_code = 0;
|
||||
|
||||
BOOST_TEST_I_TRY {
|
||||
framework::init( init_func, argc, argv );
|
||||
|
||||
if( runtime_config::get<bool>( runtime_config::WAIT_FOR_DEBUGGER ) ) {
|
||||
results_reporter::get_stream() << "Press any key to continue..." << std::endl;
|
||||
|
||||
// getchar is defined as a macro in uClibc. Use parenthesis to fix
|
||||
// gcc bug 58952 for gcc <= 4.8.2.
|
||||
(std::getchar)();
|
||||
results_reporter::get_stream() << "Continuing..." << std::endl;
|
||||
}
|
||||
|
||||
framework::finalize_setup_phase();
|
||||
|
||||
output_format list_cont = runtime_config::get<output_format>( runtime_config::LIST_CONTENT );
|
||||
if( list_cont != unit_test::OF_INVALID ) {
|
||||
if( list_cont == unit_test::OF_DOT ) {
|
||||
ut_detail::dot_content_reporter reporter( results_reporter::get_stream() );
|
||||
|
||||
traverse_test_tree( framework::master_test_suite().p_id, reporter, true );
|
||||
}
|
||||
else {
|
||||
ut_detail::hrf_content_reporter reporter( results_reporter::get_stream() );
|
||||
|
||||
traverse_test_tree( framework::master_test_suite().p_id, reporter, true );
|
||||
}
|
||||
|
||||
return boost::exit_success;
|
||||
}
|
||||
|
||||
if( runtime_config::get<bool>( runtime_config::LIST_LABELS ) ) {
|
||||
ut_detail::labels_collector collector;
|
||||
|
||||
traverse_test_tree( framework::master_test_suite().p_id, collector, true );
|
||||
|
||||
results_reporter::get_stream() << "Available labels:\n ";
|
||||
std::copy( collector.labels().begin(), collector.labels().end(),
|
||||
std::ostream_iterator<std::string>( results_reporter::get_stream(), "\n " ) );
|
||||
results_reporter::get_stream() << "\n";
|
||||
|
||||
return boost::exit_success;
|
||||
}
|
||||
|
||||
framework::run();
|
||||
|
||||
results_reporter::make_report();
|
||||
|
||||
result_code = !runtime_config::get<bool>( runtime_config::RESULT_CODE )
|
||||
? boost::exit_success
|
||||
: results_collector.results( framework::master_test_suite().p_id ).result_code();
|
||||
}
|
||||
BOOST_TEST_I_CATCH( framework::nothing_to_test, ex ) {
|
||||
result_code = ex.m_result_code;
|
||||
}
|
||||
BOOST_TEST_I_CATCH( framework::internal_error, ex ) {
|
||||
results_reporter::get_stream() << "Boost.Test framework internal error: " << ex.what() << std::endl;
|
||||
|
||||
result_code = boost::exit_exception_failure;
|
||||
}
|
||||
BOOST_TEST_I_CATCH( framework::setup_error, ex ) {
|
||||
results_reporter::get_stream() << "Test setup error: " << ex.what() << std::endl;
|
||||
|
||||
result_code = boost::exit_exception_failure;
|
||||
}
|
||||
BOOST_TEST_I_CATCHALL() {
|
||||
results_reporter::get_stream() << "Boost.Test framework internal error: unknown reason" << std::endl;
|
||||
|
||||
result_code = boost::exit_exception_failure;
|
||||
}
|
||||
|
||||
framework::shutdown();
|
||||
|
||||
return result_code;
|
||||
}
|
||||
|
||||
} // namespace unit_test
|
||||
} // namespace boost
|
||||
|
||||
#if !defined(BOOST_TEST_DYN_LINK) && !defined(BOOST_TEST_NO_MAIN)
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** main function for tests using lib ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
int BOOST_TEST_CALL_DECL
|
||||
main( int argc, char* argv[] )
|
||||
{
|
||||
// prototype for user's unit test init function
|
||||
#ifdef BOOST_TEST_ALTERNATIVE_INIT_API
|
||||
extern bool init_unit_test();
|
||||
|
||||
boost::unit_test::init_unit_test_func init_func = &init_unit_test;
|
||||
#else
|
||||
extern ::boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] );
|
||||
|
||||
boost::unit_test::init_unit_test_func init_func = &init_unit_test_suite;
|
||||
#endif
|
||||
|
||||
return ::boost::unit_test::unit_test_main( init_func, argc, argv );
|
||||
}
|
||||
|
||||
#endif // !BOOST_TEST_DYN_LINK && !BOOST_TEST_NO_MAIN
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_UNIT_TEST_MAIN_IPP_012205GER
|
||||
Reference in New Issue
Block a user