本文整理汇总了C++中NumberArray类的典型用法代码示例。如果您正苦于以下问题:C++ NumberArray类的具体用法?C++ NumberArray怎么用?C++ NumberArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NumberArray类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: filtAudio
//Compute MFCC's of the audio vector specified by audioIn
Number2DArray MfccManager::computeFeatures(
NumberArray audioIn) {
Number2DArray mfcc_13dim;
NumberArray filtAudio(audioIn.size(), 0);
Dsp::prEmpFilter(audioIn, filtAudio);
int hopLen = 0.01 * m_Fs;
// --------- Main Algo starts here ---------//
int frame, newest;
for (newest = 0, frame = 0; newest < ((int) audioIn.size() - m_winLen); newest = newest + hopLen, frame++) //
{
NumberArray input(m_winLen, 0.0);
for (int i = 0; i < m_winLen; i++) {
input[i] = filtAudio[newest + i] * hammWindow[i];
}
NumberArray mfccValues = mfcc.calculate(input);
mfcc_13dim.push_back(mfccValues);
}
Number2DArray mfcc_13_cmn;
mfcc_13_cmn = cepstralMeanNormalize(mfcc_13dim);
// Calculate Delta/Double-Delta features
return computeDeltaFeatures(mfcc_13_cmn);
}
示例2: evaluate_q
double evaluate_q (const NumberArray<NDIM, RawScalar>& xyz)
{
typedef DualNumber<RawScalar, NumberArray<NDIM, RawScalar> > FirstDerivType;
typedef DualNumber<FirstDerivType, NumberArray<NDIM, FirstDerivType> > SecondDerivType;
typedef DualNumber<SecondDerivType, NumberArray<NDIM, SecondDerivType> > ThirdDerivType;
typedef ThirdDerivType ADScalar;
// Treat velocity as a vector
NumberArray<NDIM, ADScalar> U;
ADScalar x = ADScalar(xyz[0],NumberArrayUnitVector<NDIM, 0, RawScalar>::value());
ADScalar y = ADScalar(xyz[1],NumberArrayUnitVector<NDIM, 1, RawScalar>::value());
ADScalar z = ADScalar(xyz[2],NumberArrayUnitVector<NDIM, 2, RawScalar>::value());
// Arbitrary manufactured solutions
U[0] = a * helper_f(x) + helper_g(y).derivatives()[1] + helper_h(z).derivatives()[2];
U[1] = b * helper_f(x).derivatives()[0] + helper_g(y) + helper_h(z).derivatives()[2];
U[2] = c * helper_f(x).derivatives()[0] + helper_g(y).derivatives()[1] + helper_h(z);
ADScalar P = d * helper_f(x) + helper_gt(y) + helper_h(z);
// NS equation residuals
NumberArray<NDIM, RawScalar> Q_rho_u =
raw_value(
// convective term
divergence(U.outerproduct(U))
// pressure
- P.derivatives()
// dissipation
+ nu * divergence(gradient(U)));
return raw_value(Q_rho_u[0]);
}
示例3: main
int main()
{
NumberArray first(3, 10.5);
//Make second a copy of first object
NumberArray second = first;
// Display the values of the two objects
cout << setprecision(2) << fixed << showpoint;
cout << "Value stored in first object is ";
first.print();
cout << "\nValue stored in second object is ";
second.print();
cout << "\nOnly the value in second object will "
<< "be changed.\n";
//Now change value stored in second object
second.setValue(20.5);
// Display the values stored in the two objects
cout << "Value stored in first object is ";
first.print();
cout << endl << "Value stored in second object is ";
second.print();
return 0;
}
示例4: ADScalar
Scalar MASA::navierstokes_3d_incompressible<Scalar>::eval_q_u(Scalar x1, Scalar y1, Scalar z1)
{
typedef DualNumber<Scalar, NumberArray<NDIM, Scalar> > FirstDerivType;
typedef DualNumber<FirstDerivType, NumberArray<NDIM, FirstDerivType> > SecondDerivType;
typedef DualNumber<SecondDerivType, NumberArray<NDIM, SecondDerivType> > ThirdDerivType;
typedef ThirdDerivType ADScalar;
// Treat velocity as a vector
NumberArray<NDIM, ADScalar> U;
ADScalar x = ADScalar(x1,NumberArrayUnitVector<NDIM, 0, Scalar>::value());
ADScalar y = ADScalar(y1,NumberArrayUnitVector<NDIM, 1, Scalar>::value());
ADScalar z = ADScalar(z1,NumberArrayUnitVector<NDIM, 2, Scalar>::value());
// Arbitrary manufactured solutions
U[0] = a * helper_f(beta,kx,x) * helper_g(y).derivatives()[1] * helper_h(gamma,kz,z).derivatives()[2];
U[1] = b * helper_f(beta,kx,x).derivatives()[0] * helper_g(y) * helper_h(gamma,kz,z).derivatives()[2];
U[2] = c * helper_f(beta,kx,x).derivatives()[0] * helper_g(y).derivatives()[1] * helper_h(gamma,kz,z);
ADScalar P = d * helper_f(beta,kx,x) * helper_gt(y) * helper_h(gamma,kz,z);
// NS equation residuals
NumberArray<NDIM, Scalar> Q_rho_u =
raw_value(
// convective term
divergence(U.outerproduct(U))
// pressure
- P.derivatives()
// dissipation
+ nu * divergence(gradient(U)));
return -Q_rho_u[0];
}
示例5: ADScalar
Scalar MASA::ad_cns_3d_crossterms<Scalar>::eval_q_e(Scalar x1, Scalar y1, Scalar z1) const
{
using std::cos;
typedef DualNumber<Scalar, NumberArray<NDIM, Scalar> > FirstDerivType;
typedef DualNumber<FirstDerivType, NumberArray<NDIM, FirstDerivType> > SecondDerivType;
typedef SecondDerivType ADScalar;
// Treat velocity as a vector
NumberArray<NDIM, ADScalar> U;
const ADScalar x = ADScalar(x1,NumberArrayUnitVector<NDIM, 0, Scalar>::value());
const ADScalar y = ADScalar(y1,NumberArrayUnitVector<NDIM, 1, Scalar>::value());
const ADScalar z = ADScalar(z1,NumberArrayUnitVector<NDIM, 2, Scalar>::value());
// Arbitrary manufactured solution
U[0] = u_0 + u_x * cos(a_ux * PI * x / L) * u_y * cos(a_uy * PI * y / L) * cos(a_uy * PI * z / L);
U[1] = v_0 + v_x * cos(a_vx * PI * x / L) * v_y * cos(a_vy * PI * y / L) * cos(a_vy * PI * z / L);
U[2] = w_0 + w_x * cos(a_wx * PI * x / L) * w_y * cos(a_wy * PI * y / L) * cos(a_wy * PI * z / L);
ADScalar RHO = rho_0 + rho_x * cos(a_rhox * PI * x / L) * rho_y * cos(a_rhoy * PI * y / L) * cos(a_rhoz * PI * z / L);
ADScalar P = p_0 + p_x * cos(a_px * PI * x / L) * p_y * cos(a_py * PI * y / L) * cos(a_pz * PI * z / L);
// Temperature
ADScalar T = P / RHO / R;
// Perfect gas energies
ADScalar E = 1./(Gamma-1.)*P/RHO;
ADScalar ET = E + .5 * U.dot(U);
// The shear strain tensor
NumberArray<NDIM, typename ADScalar::derivatives_type> GradU = gradient(U);
// The identity tensor I
NumberArray<NDIM, NumberArray<NDIM, Scalar> > Identity =
NumberArray<NDIM, Scalar>::identity();
// The shear stress tensor
NumberArray<NDIM, NumberArray<NDIM, ADScalar> > Tau = mu * (GradU + transpose(GradU) - 2./3.*divergence(U)*Identity);
// Temperature flux
NumberArray<NDIM, ADScalar> q = -k * T.derivatives();
// Euler equation residuals
// Scalar Q_rho = raw_value(divergence(RHO*U));
// NumberArray<NDIM, Scalar> Q_rho_u =
// raw_value(divergence(RHO*U.outerproduct(U) - Tau) + P.derivatives());
// energy equation
Scalar Q_rho_e = raw_value(divergence((RHO*ET+P)*U + q - Tau.dot(U)));
return Q_rho_e;
}
示例6: imagPart
/**
* Calculates MFCC given audio frame
*/
NumberArray Mfcc::calculate(
NumberArrayRef audioFrame) {
//------------calculate FFT-spectrum------------------//
NumberArray realPart = audioFrame;
realPart.resize(m_fftSize, 0.0); // zero padding
NumberArray imagPart(m_fftSize, 0.0);
Dsp::fft(Dsp::FORWARD_FFT, m_pow2Size, m_fftSize, realPart, imagPart);
//---------Calculate LOG of( Mel-spectrum)------------------//
NumberArray filterOutput = m_bank.applyFilter(realPart, imagPart);
//---------Calculate Mel-cepstrum------------------//
return m_dct.applyDct(filterOutput);
}
示例7: featFile
Number2DArray MfccManager::readFeatFile(
string featDir,
string fileId) {
Number2DArray featMat;
ifstream featFile((featDir + "/" + fileId + ".mfc").c_str());
string line;
if (featFile.is_open()) {
while (getline(featFile, line)) {
NumberArray featVec;
Number featVal;
stringstream ss(line);
while (ss >> featVal) {
featVec.push_back(featVal);
}
featMat.push_back(featVec);
}
featFile.close();
} else {
示例8: main
int main()
{
NumberArray first(3, 10.5);
NumberArray second = first;
std::cout << std::setprecision(2) << std::fixed << std::showpoint;
std::cout << "Value stored in first object is ";
first.print();
std::cout << std::endl << "Value stored in second object is ";
second.print();
std::cout << std::endl << "Only the value in second object is " << "will be changed." << std::endl;
second.setValue(20.5);
std::cout << "Value stored in firs object is ";
first.print();
std::cout << std::endl << "Value stored in second object is";
second.print();
return 0;
}
示例9: main
int main(int /*argc*/, char* /*argv*/[])
{
NumberArray numberArray;
std::copy(Counting(0), Counting(upperLimitSqrt), numberArray.begin());
NumberArray squareArray;
std::transform(numberArray.begin(), numberArray.end(), squareArray.begin(), boost::math::pow<2, Number>);
NumberArray squareSumArray;
Number sum = 0;
for_each_indexed(squareArray.begin(), squareArray.end(), [&](Number n, size_t i) {
sum += n;
squareSumArray[i] = sum;
});
//Number result = 0;
std::set<Number> resultSet;
for_distinct_collection(squareSumArray.begin(), squareSumArray.end(), 2,
[&](std::vector<NumberArray::iterator>::iterator begin, std::vector<NumberArray::iterator>::iterator end)
{
Number number = **(begin+1) - **begin;
if (number >= upperLimit) {
return;
}
std::string s = boost::lexical_cast<std::string>(number);
if (1 == (*(begin+1) - *begin)) {
return;
}
if (isPalindromic(s.begin(), s.end())) {
//std::cout << *begin - squareSumArray.begin() << " " << *(begin+1) - squareSumArray.begin() << std::endl;
//std::cout << "@ " << number << std::endl;
//std::cout << std::endl;
resultSet.insert(number);
//result += number;
}
}
);
std::cout << std::accumulate(resultSet.begin(), resultSet.end(), 0L) << std::endl;
}
示例10: evaluate_q
double evaluate_q (const NumberArray<NDIM, ADScalar>& xyz, const int ret)
{
typedef typename RawType<ADScalar>::value_type Scalar;
const Scalar PI = std::acos(Scalar(-1));
const Scalar k = 1.38;
const Scalar u_0 = 200.23;
const Scalar u_x = 1.1;
const Scalar u_y = 1.08;
const Scalar v_0 = 1.2;
const Scalar v_x = 1.6;
const Scalar v_y = .47;
const Scalar rho_0 = 100.02;
const Scalar rho_x = 2.22;
const Scalar rho_y = 0.8;
const Scalar p_0 = 150.2;
const Scalar p_x = .91;
const Scalar p_y = .623;
const Scalar a_px = .165;
const Scalar a_py = .612;
const Scalar a_rhox = 1.0;
const Scalar a_rhoy = 1.0;
const Scalar a_ux = .1987;
const Scalar a_uy = 1.189;
const Scalar a_vx = 1.91;
const Scalar a_vy = 1.0;
const Scalar Gamma = 1.01;
const Scalar mu = .918;
const Scalar L = 3.02;
const ADScalar& x = xyz[0];
const ADScalar& y = xyz[1];
// Treat velocity as a vector
NumberArray<NDIM, ADScalar> U;
// Arbitrary manufactured solution
U[0] = u_0 + u_x * std::sin(a_ux * PI * x / L) + u_y * std::cos(a_uy * PI * y / L);
U[1] = v_0 + v_x * std::cos(a_vx * PI * x / L) + v_y * std::sin(a_vy * PI * y / L);
ADScalar RHO = rho_0 + rho_x * std::sin(a_rhox * PI * x / L) + rho_y * std::cos(a_rhoy * PI * y / L);
ADScalar P = p_0 + p_x * std::cos(a_px * PI * x / L) + p_y * std::sin(a_py * PI * y / L);
// Perfect gas energies
ADScalar E = 1./(Gamma-1.)*P/RHO;
ADScalar ET = E + .5 * U.dot(U);
// Euler equation residuals
Scalar Q_rho = raw_value(divergence(RHO*U));
NumberArray<NDIM, Scalar> Q_rho_u = raw_value(divergence(RHO*U.outerproduct(U)) + P.derivatives());
// energy equation
Scalar Q_rho_e = raw_value(divergence((RHO*ET+P)*U));
// Scalar Q_rho_e = raw_value(divergence((RHO*U*ET)+(P*U)));
switch(ret)
{
// u
case 1:
return Q_rho_u[0];
break;
// v
case 2:
return Q_rho_u[1];
break;
// rho
case 3:
return Q_rho;
break;
// energy
case 4:
return Q_rho_e;
break;
default:
std::cout << "something is wrong!\n";
exit;
}
return 0;
}
示例11: evaluate_q
double evaluate_q (const NumberArray<NDIM, ADScalar>& xyz, const int ret)
{
typedef typename RawType<ADScalar>::value_type Scalar;
const Scalar PI = std::acos(Scalar(-1));
const Scalar R = masa_get_param("R");
const Scalar u_0 = masa_get_param("u_0");
const Scalar u_x = masa_get_param("u_x");
const Scalar u_y = masa_get_param("u_y");
const Scalar v_0 = masa_get_param("v_0");
const Scalar v_x = masa_get_param("v_x");
const Scalar v_y = masa_get_param("v_y");
const Scalar rho_0 = masa_get_param("rho_0");
const Scalar rho_x = masa_get_param("rho_x");
const Scalar rho_y = masa_get_param("rho_y");
const Scalar p_0 = masa_get_param("p_0");
const Scalar p_x = masa_get_param("p_x");
const Scalar p_y = masa_get_param("p_y");
const Scalar a_px = masa_get_param("a_px");
const Scalar a_py = masa_get_param("a_py");
const Scalar a_rhox = masa_get_param("a_rhox");
const Scalar a_rhoy = masa_get_param("a_rhoy");
const Scalar a_ux = masa_get_param("a_ux");
const Scalar a_uy = masa_get_param("a_uy");
const Scalar a_vx = masa_get_param("a_vx");
const Scalar a_vy = masa_get_param("a_vy");
const Scalar Gamma = masa_get_param("Gamma");
const Scalar L = masa_get_param("L");
const Scalar mu = masa_get_param("mu");
const Scalar k = masa_get_param("k");
const ADScalar& x = xyz[0];
const ADScalar& y = xyz[1];
// Treat velocity as a vector
NumberArray<NDIM, ADScalar> U;
// Arbitrary manufactured solution
U[0] = u_0 + u_x * std::cos(a_ux * PI * x / L) * u_y * std::cos(a_uy * PI * y / L);
U[1] = v_0 + v_x * std::cos(a_vx * PI * x / L) * v_y * std::cos(a_vy * PI * y / L);
ADScalar RHO = rho_0 + rho_x * std::cos(a_rhox * PI * x / L) * rho_y * std::cos(a_rhoy * PI * y / L);
ADScalar P = p_0 + p_x * std::cos(a_px * PI * x / L) * p_y * std::cos(a_py * PI * y / L);
// Temperature
ADScalar T = P / RHO / R;
// Perfect gas energies
ADScalar E = 1./(Gamma-1.)*P/RHO;
ADScalar ET = E + .5 * U.dot(U);
// The shear strain tensor
NumberArray<NDIM, typename ADScalar::derivatives_type> GradU = gradient(U);
// The identity tensor I
NumberArray<NDIM, NumberArray<NDIM, Scalar> > Identity =
NumberArray<NDIM, Scalar>::identity();
// The shear stress tensor
NumberArray<NDIM, NumberArray<NDIM, ADScalar> > Tau = mu * (GradU + transpose(GradU) - 2./3.*divergence(U)*Identity);
// Temperature flux
NumberArray<NDIM, ADScalar> q = -k * T.derivatives();
// Euler equation residuals
Scalar Q_rho = raw_value(divergence(RHO*U));
NumberArray<NDIM, Scalar> Q_rho_u =
raw_value(divergence(RHO*U.outerproduct(U) - Tau) + P.derivatives());
// energy equation
Scalar Q_rho_e = raw_value(divergence((RHO*ET+P)*U + q - Tau.dot(U)));
switch(ret)
{
// u
case 1:
return Q_rho_u[0];
break;
// v
case 2:
return Q_rho_u[1];
break;
// rho
case 3:
return Q_rho;
break;
// energy
case 4:
return Q_rho_e;
break;
default:
std::cout << "something is wrong!\n";
exit(1);
}
}
示例12: main
int main( int argc, const char** argv )
{
// Flags for various UI features
bool pause = false; // pause playback?
bool printFrames = false; // print frame number?
int frameDisplayFrequency = 1;
// Read through command line args, extract
// cmd line parameters and input filename
Args args;
if (!args.processArgs(argc, argv))
return -2;
string windowName = "Bin detection"; // GUI window name
string capPath; // Output directory for captured images
MediaIn* cap;
openMedia(args.inputName, cap, capPath, windowName, !args.batchMode);
if (!args.batchMode)
namedWindow(windowName, WINDOW_AUTOSIZE);
// Seek to start frame if necessary
if (args.frameStart > 0)
cap->frameCounter(args.frameStart);
Mat frame;
// Minimum size of a bin at ~30 feet distance
// TODO : Verify this once camera is calibrated
if (args.ds)
minDetectSize = cap->width() * 0.07;
else
minDetectSize = cap->width() * 0.195;
// If UI is up, pop up the parameters window
if (!args.batchMode)
{
string detectWindowName = "Detection Parameters";
namedWindow(detectWindowName);
createTrackbar ("Scale", detectWindowName, &scale, 50, NULL);
createTrackbar ("Neighbors", detectWindowName, &neighbors, 50, NULL);
createTrackbar ("Min Detect", detectWindowName, &minDetectSize, 200, NULL);
createTrackbar ("Max Detect", detectWindowName, &maxDetectSize, max(cap->width(), cap->height()), NULL);
}
// Create list of tracked objects
// recycling bins are 24" wide
TrackedObjectList binTrackingList(24.0, cap->width());
NetworkTable::SetClientMode();
NetworkTable::SetIPAddress("10.9.0.2");
NetworkTable *netTable = NetworkTable::GetTable("VisionTable");
const size_t netTableArraySize = 7; // 7 bins?
NumberArray netTableArray;
// 7 bins max, 3 entries each (confidence, distance, angle)
netTableArray.setSize(netTableArraySize * 3);
// Code to write video frames to avi file on disk
VideoWriter outputVideo;
VideoWriter markedupVideo;
args.writeVideo = netTable->GetBoolean("WriteVideo", args.writeVideo);
const int videoWritePollFrequency = 30; // check for network table entry every this many frames (~5 seconds or so)
int videoWritePollCount = videoWritePollFrequency;
FrameTicker frameTicker;
DetectState detectState(
ClassifierIO(args.classifierBaseDir, args.classifierDirNum, args.classifierStageNum),
gpu::getCudaEnabledDeviceCount() > 0);
// Start of the main loop
// -- grab a frame
// -- update the angle of tracked objects
// -- do a cascade detect on the current frame
// -- add those newly detected objects to the list of tracked objects
while(cap->getNextFrame(frame, pause))
{
frameTicker.start(); // start time for this frame
if (--videoWritePollCount == 0)
{
args.writeVideo = netTable->GetBoolean("WriteVideo", args.writeVideo);
videoWritePollCount = videoWritePollFrequency;
}
if (args.writeVideo)
writeVideoToFile(outputVideo, getVideoOutName().c_str(), frame, netTable, true);
//TODO : grab angle delta from robot
// Adjust the position of all of the detected objects
// to account for movement of the robot between frames
double deltaAngle = 0.0;
binTrackingList.adjustAngle(deltaAngle);
// This code will load a classifier if none is loaded - this handles
// initializing the classifier the first time through the loop.
// It also handles cases where the user changes the classifer
// being used - this forces a reload
// Finally, it allows a switch between CPU and GPU on the fly
if (detectState.update() == false)
//.........这里部分代码省略.........