本文整理汇总了C++中DoubleMatrix::at方法的典型用法代码示例。如果您正苦于以下问题:C++ DoubleMatrix::at方法的具体用法?C++ DoubleMatrix::at怎么用?C++ DoubleMatrix::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoubleMatrix
的用法示例。
在下文中一共展示了DoubleMatrix::at方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: chartData
void chartData(std::vector<double>& results, bool cluster, int subjectBond, DoubleMatrix data, long* maturities, int date_tolerance, int lower_date, int upper_date, int length){
DoubleMatrix lowerBonds;
DoubleMatrix upperBonds;
std::vector<double>timeSeries;
upperAndLowerBonds(cluster, subjectBond, data, maturities, date_tolerance, lower_date, upper_date, upperBonds, lowerBonds);
flyTimeSeries(results, lowerBonds, data.at(subjectBond), upperBonds, length);
}
示例2: MatrixHeatImaging
void MatrixHeatImaging(const DoubleMatrix &m, double minimum, double maximum, QPixmap &pixmap, int width, int height)
{
pixmap = QPixmap(QSize(width, height));
pixmap.fill(Qt::white);
QPainter painter(&pixmap);
unsigned int rows = m.rows();
unsigned int cols = m.cols();
for (unsigned int j=0; j<rows; j++)
{
for (unsigned int i=0; i<cols; i++)
{
double u = m.at(j,i);
double ratio = 0.0;
if (minimum!=maximum)
ratio = 2.0 * (u-minimum) / (maximum - minimum);
int b = int(MAX(0, 255*(1 - ratio)));
int r = int(MAX(0, 255*(ratio - 1)));
int g = 255 - b - r;
QColor c(r, g, b);
painter.setPen(c);
painter.drawPoint(i,height-j-1);
}
}
}
示例3: getFlyMetrics
void getFlyMetrics(double* results, bool cluster, int subjectBond, DoubleMatrix data, long* maturities, int date_tolerance, int lower_date, int upper_date, int length){
DoubleMatrix lowerBonds;
DoubleMatrix upperBonds;
std::vector<double>timeSeries;
upperAndLowerBonds(cluster, subjectBond, data, maturities, date_tolerance, lower_date, upper_date, upperBonds, lowerBonds);
bool dataExists = flyTimeSeries(timeSeries, lowerBonds, data.at(subjectBond), upperBonds, length);
if (dataExists){
flyMetrics(results, timeSeries);
}
else{
for (int i = 0; i < 8; i++){
results[i] = 0;
}
}
}
示例4: getChartData
long _stdcall getChartData(int bond_id, bool cluster, double* arr, unsigned char bonds[], int numbonds, long* maturities, int microWidth, int dateTolerance, int clusterLower, int clusterUpper, int history){
SimpleRefData bbg(1);
DoubleMatrix yieldData;
std::vector <std::string> bond_vec;
for (int b = 0; b < numbonds; b++){
std::string prefix = "/isin/";
std::string suffix;
suffix.clear();
for (int j = 0; j < ISIN_LENGTH; j++){
char a = bonds[b + j*(numbonds + 1)];
suffix += a;
}
bond_vec.push_back((prefix + suffix).c_str());
}
double** yieldArray;
yieldArray = new double*[numbonds+1];
for (int i = 0; i <= numbonds; i++){
yieldArray[i] = new double[history];
}
int days_data = bbg.runHistData(yieldArray, bond_vec, history);
yieldData.resize(numbonds);
for (int i = 0; i <= numbonds; i++){
yieldData[i].resize(days_data);
}
for (int i = 0; i <= numbonds; i++){
for (int j = 0; j < days_data; j++){
yieldData.at(i).at(j) = yieldArray[i][j];
}
}
std::vector<double> dataLocal;
if (cluster){
chartData(dataLocal, cluster, bond_id, yieldData, maturities, 0, clusterLower, clusterUpper, days_data);
}
else{
chartData(dataLocal, cluster, bond_id, yieldData, maturities, dateTolerance, microWidth, microWidth, days_data);
}
for (int i = 0; i < days_data; i++){
arr[i] = dataLocal.at(i);
}
return days_data;
}
示例5: assertSizeEqual
/*!
* \brief sumMatrices Sums the two matrices given as parameters in parallel.
* Spawns threadCount threads for this operation.
* \param A First matrix - a vector of double precision floating-point values.
* \param B Second matrix.
* \param threadCount Number of threads to spawn in the parallel OpenMP block.
* \return Third matrix - the result of addition of A and B matrices.
*/
const DoubleMatrix *sumMatrices(const DoubleMatrix &A, const DoubleMatrix &B,
unsigned int threadCount)
{
assertSizeEqual(A, B);
DoubleMatrix *C = new DoubleMatrix();
fillMatrixWithZeros(*C, A.size());
#pragma omp parallel for default(none) shared(A, B, C) num_threads(threadCount)
for (unsigned int k = 0; k < 10000; ++k)
{
for (unsigned int i = 0; i < A.size(); i++)
{
C->at(i) = A.at(i) + B.at(i);
}
}
return C;
}
示例6: getFlyData
/*Inputs: Destinaion Excel grid, array of ISINS, number of bonds, array of maturities, date tolerance for flies, */
long _stdcall getFlyData(double* arr, unsigned char bonds[], int numbonds, long* maturities, int microWidth, int dateTolerance, int clusterLower, int clusterUpper, int history){
SimpleRefData bbg(1);
DoubleMatrix yieldData;
DoubleMatrix micro;
DoubleMatrix cluster;
std::vector <std::string> bond_vec;
std::wstring stemp2 = std::to_wstring(numbonds);
LPCWSTR sw2 = stemp2.c_str();
OutputDebugString(L"numbonds ");
OutputDebugString(sw2);
for (int b = 0; b <= numbonds; b++){
std::string prefix = "/isin/";
std::string suffix;
suffix.clear();
for (int j = 0; j < ISIN_LENGTH; j++){
char a = bonds[b + j*(numbonds + 1)];
suffix += a;
}
std::wstring stemp = std::wstring(suffix.begin(), suffix.end());
LPCWSTR sw = stemp.c_str();
OutputDebugString(sw);
OutputDebugString(L"\n");
bond_vec.push_back((prefix + suffix).c_str());
}
double** yieldArray;
yieldArray = new double*[numbonds+1];
for (int i = 0; i <= numbonds; i++){
yieldArray[i] = new double[history];
}
int days_data = bbg.runHistData(yieldArray, bond_vec, history);
std::wstring stemp = std::to_wstring(days_data);
LPCWSTR sw = stemp.c_str();
OutputDebugString(sw);
yieldData.resize(numbonds+1);
for (int i = 0; i <= numbonds; i++){
yieldData[i].resize(days_data);
}
for (int i = 0; i <= numbonds; i++){
for (int j = 0; j < days_data; j++){
yieldData.at(i).at(j) = yieldArray[i][j];
}
}
DoubleMatrix microMatrix;
DoubleMatrix clusterMatrix;
for (int i = 0; i < numbonds; i++){
double microLocal[8];
double clusterLocal[8];
getFlyMetrics(microLocal, false, i, yieldData, maturities, dateTolerance, microWidth, microWidth, days_data);
getFlyMetrics(clusterLocal, true, i, yieldData, maturities, 0, clusterLower, clusterUpper, days_data);
double flyLocal[16];
for (int j = 0; j < 8; j++){
flyLocal[j] = microLocal[j];
flyLocal[8 + j] = clusterLocal[j];
}
for (int k = 0; k < 16; k++){
arr[i + k*(numbonds + 1)] = flyLocal[k];
}
}
delete[] yieldArray;
return 0;
}