本文整理汇总了C++中complex函数的典型用法代码示例。如果您正苦于以下问题:C++ complex函数的具体用法?C++ complex怎么用?C++ complex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了complex函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: exp
/* -*- C++ -*- */
/*************************************************************************
* Copyright(c) 1995~2005 Masaharu Goto ([email protected])
*
* For the licensing terms see the file COPYING
*
************************************************************************/
/*************************************************************************
* eular.c
*
* array pre-compiled class library is needed to run this demo program.
*************************************************************************/
#include <array.h>
const complex j=complex(0,1);
const double PI=3.141592;
main() {
array x=array(-2*PI , 2*PI , 100 ); // start,stop,npoint
plot << "Eular's Law" << x << exp(x*j) << "exp(x*j)" << endl ;
}
开发者ID:309972460,项目名称:software,代码行数:20,代码来源:eular.c
示例2: OBJECTHDR
//.........这里部分代码省略.........
if(ice_making <=ice_making_probability)
{
check_icemaking = true;
icemaker_running = true;
// ice_making_no = gl_random_sampled(3,ice_making_time);
ice_making_no = 1;
posted_power += icemaking_power;
return_time = 60;
ice_making_no--;
if(ice_making_no == 0)
{
check_icemaking = false;
}
}
else
{
icemaker_running = false;
return_time = 60;
}
}
else
{
icemaker_running = false;
}
}
load.power.SetPowerFactor(posted_power/1000, load.power_factor);
load.admittance = complex(0,0,J);
load.current = complex(0,0,J);
if(true==door_open && true==door_to_open)
{
door_time = door_return_time<door_next_open_time?door_return_time:door_next_open_time;
}
else if(true==door_to_open)
{
door_time = door_next_open_time;
}
else if(true==door_open){
door_time = door_return_time;
}
else if(start_time>0)
{
door_time = (3600 - ((t1-start_time)%3600));
}
if(0.0==return_time)
{
dt1 = cycle_time>door_time?door_time:cycle_time;
}
else
{
if(cycle_time>return_time)
if(return_time>door_time)
if(door_time>long_compressor_cycle_time)
dt1 = long_compressor_cycle_time;
else
dt1 = door_time;
开发者ID:Terrenceli,项目名称:residential2,代码行数:67,代码来源:refrigerator.cpp
示例3: OBJECTHDR
TIMESTAMP house::sync_panel(TIMESTAMP t0, TIMESTAMP t1)
{
TIMESTAMP sync_time = TS_NEVER;
OBJECT *obj = OBJECTHDR(this);
// clear accumulators for panel currents
complex I[3]; I[X12] = I[X23] = I[X13] = complex(0,0);
// clear heatgain accumulator
double heatgain = 0;
// gather load power and compute current for each circuit
CIRCUIT *c;
for (c=panel.circuits; c!=NULL; c=c->next)
{
// get circuit type
int n = (int)c->type;
if (n<0 || n>2)
GL_THROW("%s:%d circuit %d has an invalid circuit type (%d)", obj->oclass->name, obj->id, c->id, (int)c->type);
/* TROUBLESHOOT
Invalid circuit types are an internal error for the house panel. Please report this error. The likely causes
include an object that is not a house is being processed by the house model, or the panel was not correctly
initialized.
*/
// if breaker is open and reclose time has arrived
if (c->status==BRK_OPEN && t1>=c->reclose)
{
c->status = BRK_CLOSED;
c->reclose = TS_NEVER;
sync_time = t1; // must immediately reevaluate devices affected
gl_debug("house:%d panel breaker %d closed", obj->id, c->id);
}
// if breaker is closed
if (c->status==BRK_CLOSED)
{
// compute circuit current
if ((c->pV)->Mag() == 0)
{
gl_debug("house:%d circuit %d (enduse %s) voltage is zero", obj->id, c->id, c->pLoad->name);
break;
}
complex current = ~(c->pLoad->total*1000 / *(c->pV));
// check breaker
if (c->max_amps>0 && current.Mag()>c->max_amps)
{
// probability of breaker failure increases over time
if (c->tripsleft>0 && gl_random_bernoulli(1/(c->tripsleft--))==0)
{
// breaker opens
c->status = BRK_OPEN;
// average five minutes before reclosing, exponentially distributed
c->reclose = t1 + (TIMESTAMP)(gl_random_exponential(1/300.0)*TS_SECOND);
gl_debug("house:%d circuit breaker %d tripped - enduse %s overload at %.0f A", obj->id, c->id,
c->pLoad->name, current.Mag());
}
// breaker fails from too frequent operation
else
{
c->status = BRK_FAULT;
c->reclose = TS_NEVER;
gl_debug("house:%d circuit breaker %d failed", obj->id, c->id);
}
// must immediately reevaluate everything
sync_time = t1;
}
// add to panel current
else
{
tload.power += c->pLoad->power; // reminder: |a| + |b| != |a+b|
tload.current += c->pLoad->current;
tload.admittance += c->pLoad->admittance; // should this be additive? I don't buy t.a = c->pL->a ... -MH
tload.total += c->pLoad->total;
tload.heatgain += c->pLoad->heatgain;
tload.energy += c->pLoad->power * gl_tohours(t1-t0);
I[n] += current;
c->reclose = TS_NEVER;
}
}
// sync time
if (sync_time > c->reclose)
sync_time = c->reclose;
}
// compute line currents and post to meter
if (obj->parent != NULL)
LOCK_OBJECT(obj->parent);
pLine_I[0] = I[X13];
pLine_I[1] = I[X23];
pLine_I[2] = 0;
*pLine12 = I[X12];
//.........这里部分代码省略.........
开发者ID:Terrenceli,项目名称:residential2,代码行数:101,代码来源:house_a.cpp
示例4: analyzeTrafficBurst
bool analyzeTrafficBurst(signalVector &rxBurst,
unsigned TSC,
float detectThreshold,
int samplesPerSymbol,
complex *amplitude,
float *TOA,
unsigned maxTOA,
bool requestChannel,
signalVector **channelResponse,
float *channelResponseOffset)
{
assert(TSC<8);
assert(amplitude);
assert(TOA);
assert(gMidambles[TSC]);
if (maxTOA < 3*samplesPerSymbol) maxTOA = 3*samplesPerSymbol;
unsigned spanTOA = maxTOA;
if (spanTOA < 5*samplesPerSymbol) spanTOA = 5*samplesPerSymbol;
unsigned startIx = (66-spanTOA)*samplesPerSymbol;
unsigned endIx = (66+16+spanTOA)*samplesPerSymbol;
unsigned windowLen = endIx - startIx;
unsigned corrLen = 2*maxTOA+1;
unsigned expectedTOAPeak = (unsigned) round(gMidambles[TSC]->TOA + (gMidambles[TSC]->sequenceReversedConjugated->size()-1)/2);
signalVector burstSegment(rxBurst.begin(),startIx,windowLen);
static complex staticData[200];
signalVector correlatedBurst(staticData,0,corrLen);
correlate(&burstSegment, gMidambles[TSC]->sequenceReversedConjugated,
&correlatedBurst, CUSTOM,true,
expectedTOAPeak-maxTOA,corrLen);
float meanPower;
*amplitude = peakDetect(correlatedBurst,TOA,&meanPower);
float valleyPower = 0.0; //amplitude->norm2();
complex *peakPtr = correlatedBurst.begin() + (int) rint(*TOA);
// check for bogus results
if ((*TOA < 0.0) || (*TOA > correlatedBurst.size())) {
*amplitude = 0.0;
return false;
}
int numRms = 0;
for (int i = 2*samplesPerSymbol; i <= 5*samplesPerSymbol;i++) {
if (peakPtr - i >= correlatedBurst.begin()) {
valleyPower += (peakPtr-i)->norm2();
numRms++;
}
if (peakPtr + i < correlatedBurst.end()) {
valleyPower += (peakPtr+i)->norm2();
numRms++;
}
}
if (numRms < 2) {
// check for bogus results
*amplitude = 0.0;
return false;
}
float RMS = sqrtf(valleyPower/(float)numRms)+0.00001;
float peakToMean = (amplitude->abs())/RMS;
// NOTE: Because ideal TSC is 66 symbols into burst,
// the ideal TSC has an +/- 180 degree phase shift,
// due to the pi/4 frequency shift, that
// needs to be accounted for.
*amplitude = (*amplitude)/gMidambles[TSC]->gain;
*TOA = (*TOA) - (maxTOA);
LOG(DEBUG) << "TCH peakAmpl=" << amplitude->abs() << " RMS=" << RMS << " peakToMean=" << peakToMean << " TOA=" << *TOA;
LOG(DEBUG) << "autocorr: " << correlatedBurst;
if (requestChannel && (peakToMean > detectThreshold)) {
float TOAoffset = maxTOA; //gMidambles[TSC]->TOA+(66*samplesPerSymbol-startIx);
delayVector(correlatedBurst,-(*TOA));
// midamble only allows estimation of a 6-tap channel
signalVector channelVector(6*samplesPerSymbol);
float maxEnergy = -1.0;
int maxI = -1;
for (int i = 0; i < 7; i++) {
if (TOAoffset+(i-5)*samplesPerSymbol + channelVector.size() > correlatedBurst.size()) continue;
if (TOAoffset+(i-5)*samplesPerSymbol < 0) continue;
correlatedBurst.segmentCopyTo(channelVector,(int) floor(TOAoffset+(i-5)*samplesPerSymbol),channelVector.size());
float energy = vectorNorm2(channelVector);
if (energy > 0.95*maxEnergy) {
maxI = i;
maxEnergy = energy;
}
}
*channelResponse = new signalVector(channelVector.size());
correlatedBurst.segmentCopyTo(**channelResponse,(int) floor(TOAoffset+(maxI-5)*samplesPerSymbol),(*channelResponse)->size());
//.........这里部分代码省略.........
开发者ID:kluchnikov,项目名称:openbts-2.6-gprs,代码行数:101,代码来源:sigProcLib.cpp
示例5: _complex
/*!
\deprecated use standard contructors for typecasting
\sa cxsc::complex::complex(const cdotprecision &)
*/
friend inline complex _complex(const cdotprecision &a) throw() { return complex(a); }
开发者ID:skempken,项目名称:interverdikom,代码行数:6,代码来源:complex.hpp
示例6: fn_init
scalar fn_init(double x, double y, scalar& dx, scalar& dy) {
return complex(exp(-10*(x*x + y*y)), 0);
}
开发者ID:Richardma,项目名称:hermes2d,代码行数:3,代码来源:main.cpp
示例7: exp
/** exponentioal of a complex number
\ingroup complex
\param[in] z Complex number
\return \f$ e^z \f$*/
complex exp(const complex& z)
{
return complex(gsl_complex_exp(z.as_gsl_type()));
}
开发者ID:shehu0,项目名称:HEPfit,代码行数:8,代码来源:gslpp_complex.cpp
示例8: log10
/** Logarithm of a complex number (base 10)
\ingroup complex
\param[in] z Complex number
\return \f$ \log_{10} z \f$*/
complex log10(const complex& z)
{
return complex(gsl_complex_log10(z.as_gsl_type()));
}
开发者ID:shehu0,项目名称:HEPfit,代码行数:8,代码来源:gslpp_complex.cpp
示例9: gsl_complex_conjugate
complex complex::conjugate() const
{
gsl_complex t = gsl_complex_conjugate(_complex);
return complex(t);
}
开发者ID:shehu0,项目名称:HEPfit,代码行数:5,代码来源:gslpp_complex.cpp
示例10: gsl_complex_inverse
complex complex::inverse() const
{
gsl_complex t = gsl_complex_inverse(_complex);
return complex(t);
}
开发者ID:shehu0,项目名称:HEPfit,代码行数:5,代码来源:gslpp_complex.cpp
示例11: gsl_complex_div_real
complex complex::operator/(const double& a) const
{
gsl_complex rl = gsl_complex_div_real(_complex,a);
return complex(rl);
}
开发者ID:shehu0,项目名称:HEPfit,代码行数:5,代码来源:gslpp_complex.cpp
示例12: gsl_complex_div
complex complex::operator/(const complex& z1) const
{
gsl_complex rl = gsl_complex_div(_complex, z1._complex);
return complex(rl);
}
开发者ID:shehu0,项目名称:HEPfit,代码行数:5,代码来源:gslpp_complex.cpp
示例13: gsl_complex_negative
complex complex::operator-() const
{
gsl_complex t = gsl_complex_negative(_complex);
return complex(&t);
}
开发者ID:shehu0,项目名称:HEPfit,代码行数:5,代码来源:gslpp_complex.cpp
示例14: csch
/** Hyperbolic cosecant
\ingroup complex
\param[in] z Complex number
\return \f$ \mathrm{csch} z \f$*/
complex csch(const complex& z)
{
return complex(gsl_complex_csch(z.as_gsl_type()));
}
开发者ID:shehu0,项目名称:HEPfit,代码行数:8,代码来源:gslpp_complex.cpp
示例15: log
/** Logarithm of a complex number (base b)
\ingroup complex
\param[in] z Complex number
\param[in] b Complex number
\return \f$ \log_b z \f$*/
complex log(const complex& z,
const complex& b)
{
return complex(gsl_complex_log_b(z.as_gsl_type(),b.as_gsl_type()));
}
开发者ID:shehu0,项目名称:HEPfit,代码行数:10,代码来源:gslpp_complex.cpp
示例16: arccoth
/** Inverse hyperbolic cotangent
\ingroup complex
\param[in] z Complex number
\return \f$ \mathrm{acoth}(z) \f$*/
complex arccoth(const complex& z)
{
return complex(gsl_complex_arccoth(z.as_gsl_type()));
}
开发者ID:shehu0,项目名称:HEPfit,代码行数:8,代码来源:gslpp_complex.cpp
示例17: Li_2
/** DiLogarithm of a complex number
\ingroup complex
\param[in] z Complex number
\return \f$ Li_2(z) \f$*/
complex dilog(const complex& z)
{
gsl_sf_result re, im;
gsl_sf_complex_dilog_xy_e(z.real(), z.imag(), &re, &im);
return complex(re.val, im.val, false);
}
开发者ID:shehu0,项目名称:HEPfit,代码行数:10,代码来源:gslpp_complex.cpp
示例18: sqrt
/** Square root of a complex number
\ingroup complex
\param[in] z Complex number
\return \f$ \sqrt z \f$*/
complex sqrt(const complex& z)
{
return complex(gsl_complex_sqrt(z.as_gsl_type()));
}
开发者ID:shehu0,项目名称:HEPfit,代码行数:8,代码来源:gslpp_complex.cpp
示例19: bc_values
complex bc_values(int marker, double x, double y)
{
return complex(0.0, 0.0);
}
开发者ID:Richardma,项目名称:hermes2d,代码行数:4,代码来源:main.cpp
示例20: pow
/** Complex number to the z2 complex order
\ingroup complex
\param[in] z1 Complex number
\param[in] z2 Complex number
\return \f$ z_1^{z_2} \f$*/
complex pow(const complex& z1,
const complex& z2)
{
return complex(gsl_complex_pow(z1.as_gsl_type(),
z2.as_gsl_type()));
}
开发者ID:shehu0,项目名称:HEPfit,代码行数:11,代码来源:gslpp_complex.cpp
注:本文中的complex函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论