本文整理汇总了C++中std::isnormal方法的典型用法代码示例。如果您正苦于以下问题:C++ std::isnormal方法的具体用法?C++ std::isnormal怎么用?C++ std::isnormal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std
的用法示例。
在下文中一共展示了std::isnormal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNearestMiddle
RS_Vector RS_Arc::getNearestMiddle(const RS_Vector& coord,
double* dist,
int middlePoints
)const {
#ifndef EMU_C99
using std::isnormal;
#endif
RS_DEBUG->print("RS_Arc::getNearestMiddle(): begin\n");
double amin=getAngle1();
double amax=getAngle2();
//std::cout<<"RS_Arc::getNearestMiddle(): middlePoints="<<middlePoints<<std::endl;
if( !(/*std::*/isnormal(amin) || /*std::*/isnormal(amax))){
//whole circle, no middle point
if(dist != NULL) {
*dist=RS_MAXDOUBLE;
}
return RS_Vector(false);
}
if(isReversed()) {
std::swap(amin,amax);
}
double da=fmod(amax-amin+2.*M_PI, 2.*M_PI);
if ( da < RS_TOLERANCE ) {
da= 2.*M_PI; // whole circle
}
RS_Vector vp(getNearestPointOnEntity(coord,true,dist));
double angle=getCenter().angleTo(vp);
int counts=middlePoints+1;
int i( static_cast<int>(fmod(angle-amin+2.*M_PI,2.*M_PI)/da*counts+0.5));
if(!i) i++; // remove end points
if(i==counts) i--;
angle=amin + da*(double(i)/double(counts));
vp.setPolar(getRadius(), angle);
vp.move(getCenter());
if (dist) {
*dist = vp.distanceTo(coord);
}
RS_DEBUG->print("RS_Arc::getNearestMiddle(): end\n");
return vp;
}
示例2: set
void set(const rapidjson::Value& object) {
using std::isnormal;
if (not object.HasMember("save-mhd-n")) {
throw std::invalid_argument(
std::string(__FILE__ "(") + std::to_string(__LINE__) + "): "
+ "JSON data doesn't have a save-mhd-n key."
);
}
save_mhd_n = object["save-mhd-n"].GetDouble();
if (not object.HasMember("time-start")) {
throw std::invalid_argument(
std::string(__FILE__ "(") + std::to_string(__LINE__) + "): "
+ "JSON data doesn't have a time-start key."
);
}
time_start = object["time-start"].GetDouble();
if (not object.HasMember("time-length")) {
throw std::invalid_argument(
std::string(__FILE__ "(") + std::to_string(__LINE__) + "): "
+ "JSON data doesn't have a time-length key."
);
}
time_length = object["time-length"].GetDouble();
if (not object.HasMember("time-step-factor")) {
throw std::invalid_argument(
std::string(__FILE__ "(") + std::to_string(__LINE__) + "): "
+ "JSON data doesn't have a time-step-factor key."
);
}
time_step_factor = object["time-step-factor"].GetDouble();
if (not object.HasMember("remove-div-B-n")) {
throw std::invalid_argument(
std::string(__FILE__ "(") + std::to_string(__LINE__) + "): "
+ "JSON data doesn't have a remove-div-B-n key."
);
}
remove_div_B_n = object["remove-div-B-n"].GetDouble();
if (not object.HasMember("poisson-norm-stop")) {
throw std::invalid_argument(
std::string(__FILE__ "(") + std::to_string(__LINE__) + "): "
+ "JSON data doesn't have a poisson-norm-stop key."
);
}
poisson_norm_stop = object["poisson-norm-stop"].GetDouble();
if (not object.HasMember("poisson-norm-increase-max")) {
throw std::invalid_argument(
std::string(__FILE__ "(") + std::to_string(__LINE__) + "): "
+ "JSON data doesn't have a poisson-norm-increase-max key."
);
}
poisson_norm_increase_max = object["poisson-norm-increase-max"].GetDouble();
if (not object.HasMember("adiabatic-index")) {
throw std::invalid_argument(
std::string(__FILE__ "(") + std::to_string(__LINE__) + "): "
+ "JSON data doesn't have a adiabatic-index key."
);
}
adiabatic_index = object["adiabatic-index"].GetDouble();
if (not isnormal(adiabatic_index) or adiabatic_index < 0) {
throw std::invalid_argument(
std::string(__FILE__ "(") + std::to_string(__LINE__) + "): "
+ "Invalid adiabatic index: " + std::to_string(adiabatic_index)
+ ", should be > 0"
);
}
if (not object.HasMember("vacuum-permeability")) {
throw std::invalid_argument(
std::string(__FILE__ "(") + std::to_string(__LINE__) + "): "
+ "JSON data doesn't have a vacuum-permeability key."
);
}
vacuum_permeability = object["vacuum-permeability"].GetDouble();
if (not isnormal(vacuum_permeability) or vacuum_permeability < 0) {
throw std::invalid_argument(
std::string(__FILE__ "(") + std::to_string(__LINE__) + "): "
+ "Invalid vacuum permeability: " + std::to_string(vacuum_permeability)
+ ", should be > 0"
);
}
if (not object.HasMember("proton-mass")) {
throw std::invalid_argument(
std::string(__FILE__ "(") + std::to_string(__LINE__) + "): "
+ "JSON data doesn't have a proton-mass key."
);
}
proton_mass = object["proton-mass"].GetDouble();
if (not isnormal(proton_mass) or proton_mass < 0) {
throw std::invalid_argument(
std::string(__FILE__ "(") + std::to_string(__LINE__) + "): "
+ "Invalid proton_mass: " + std::to_string(proton_mass)
//.........这里部分代码省略.........
示例3: isArc
/**
* is the Ellipse an Arc
* @return false, if both angle1/angle2 are zero
*
*Author: Dongxu Li
*/
bool RS_Ellipse::isArc() const{
#ifndef EMU_C99
using std::isnormal;
#endif
return /*std::*/isnormal(getAngle1()) || /*std::*/isnormal(getAngle2());
}
示例4: get_flux_rusanov
> std::tuple<MHD, double> get_flux_rusanov(
MHD& state_neg,
MHD& state_pos,
const Vector& bg_face_magnetic_field,
const double& area,
const double& dt,
const double& adiabatic_index,
const double& vacuum_permeability
) {
using std::isnormal;
using std::isfinite;
using std::to_string;
const Mass_Density Mas{};
const Momentum_Density Mom{};
const Total_Energy_Density Nrj{};
const Magnetic_Field Mag{};
if (not isnormal(state_neg[Mas]) or state_neg[Mas] < 0) {
throw std::domain_error(
"Invalid mass density in state_neg: "
+ to_string(state_neg[Mas])
);
}
if (not isnormal(state_pos[Mas]) or state_pos[Mas] < 0) {
throw std::domain_error(
"Invalid mass density in state_pos: "
+ to_string(state_pos[Mas])
);
}
const auto
fast_magnetosonic_neg
= get_fast_magnetosonic_speed(
state_neg[Mas],
state_neg[Mom],
state_neg[Nrj],
state_neg[Mag],
bg_face_magnetic_field,
adiabatic_index,
vacuum_permeability
),
fast_magnetosonic_pos
= get_fast_magnetosonic_speed(
state_pos[Mas],
state_pos[Mom],
state_pos[Nrj],
state_pos[Mag],
bg_face_magnetic_field,
adiabatic_index,
vacuum_permeability
),
max_fast_ms = std::max(fast_magnetosonic_neg, fast_magnetosonic_pos),
max_signal = std::max(
std::abs(state_neg[Mom][0] / state_neg[Mas]) + max_fast_ms,
std::abs(state_pos[Mom][0] / state_pos[Mas]) + max_fast_ms
);
const auto Mas_getter
= [](MHD& state) -> typename Mass_Density::data_type& {
return state[Mass_Density()];
};
const auto Mom_getter
= [](MHD& state) -> typename Momentum_Density::data_type& {
return state[Momentum_Density()];
};
const auto Nrj_getter
= [](MHD& state) -> typename Total_Energy_Density::data_type& {
return state[Total_Energy_Density()];
};
const auto Mag_getter
= [](MHD& state) -> typename Magnetic_Field::data_type& {
return state[Magnetic_Field()];
};
MHD
flux_neg
= get_flux(
state_neg,
bg_face_magnetic_field,
adiabatic_index,
vacuum_permeability,
Mas_getter, Mom_getter, Nrj_getter, Mag_getter
),
flux_pos
= get_flux(
state_pos,
bg_face_magnetic_field,
adiabatic_index,
vacuum_permeability,
Mas_getter, Mom_getter, Nrj_getter, Mag_getter
);
MHD flux
= (flux_neg + flux_pos) / 2
- (state_pos - state_neg) * (max_signal / 2);
flux *= area * dt;
//.........这里部分代码省略.........