本文整理汇总了C++中TwoDArray::getNumCols方法的典型用法代码示例。如果您正苦于以下问题:C++ TwoDArray::getNumCols方法的具体用法?C++ TwoDArray::getNumCols怎么用?C++ TwoDArray::getNumCols使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwoDArray
的用法示例。
在下文中一共展示了TwoDArray::getNumCols方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSimpleTestTwoDArray
TEUCHOS_UNIT_TEST(Teuchos_TwoDArray, resizeTest){
TwoDArray<int> simpleArray = getSimpleTestTwoDArray();
simpleArray.resizeRows(4);
TEST_EQUALITY_CONST(simpleArray.getNumRows(), 4);
TEST_EQUALITY_CONST(simpleArray.getNumCols(), 2);
TEST_EQUALITY_CONST(simpleArray(3,1), 0);
TEST_EQUALITY_CONST(simpleArray(1,1), 4);
simpleArray.resizeRows(2);
TEST_EQUALITY_CONST(simpleArray.getNumRows(), 2);
TEST_EQUALITY_CONST(simpleArray.getNumCols(), 2);
#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
TEST_THROW(simpleArray(3,1), RangeError);
#endif
TEST_EQUALITY_CONST(simpleArray(1,1), 4);
simpleArray.resizeCols(4);
TEST_EQUALITY_CONST(simpleArray.getNumCols(), 4);
TEST_EQUALITY_CONST(simpleArray.getNumRows(), 2);
TEST_EQUALITY_CONST(simpleArray(1,3), 0);
TEST_EQUALITY_CONST(simpleArray(1,1), 4);
simpleArray.resizeCols(2);
TEST_EQUALITY_CONST(simpleArray.getNumCols(), 2);
TEST_EQUALITY_CONST(simpleArray.getNumRows(), 2);
#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
TEST_THROW(simpleArray(1,3), RangeError);
#endif
TEST_EQUALITY_CONST(simpleArray(1,1), 4);
}
示例2:
TEST(TwoDArrayCol, NumCol) {
TwoDArray<int>* tDInt = new TwoDArray<int>(10, 10, 0);
TwoDArray<double>* tDDouble = new TwoDArray<double>(11, 11, 0.0);
TwoDArray<string>* tDString = new TwoDArray<string>(12, 12, "0");
EXPECT_EQ(10, tDInt->getNumCols());
delete tDInt;
EXPECT_EQ(11, tDDouble->getNumCols());
delete tDDouble;
EXPECT_EQ(12, tDString->getNumCols());
delete tDString;
}
示例3:
TEST(TwoDArray, GetNumCols) {
TwoDArray<int>* newArray = new TwoDArray<int>(7,8,0);
EXPECT_EQ(7, newArray->getNumCols());
delete newArray;
TwoDArray<double>* newDouble = new TwoDArray<double>(562,786,1.2);
EXPECT_EQ(562, newDouble->getNumCols());
delete newDouble;
TwoDArray<std::string>* newString = new TwoDArray<std::string>(5,6, "bye");
EXPECT_EQ(5, newString->getNumCols());
delete newString;
}
示例4:
TEST(numCols, stringTest) {
int r = 5;
int c = 10;
TwoDArray<string>* a = new TwoDArray<string>(r, c);
EXPECT_EQ(10, a->getNumCols());
delete a;
}
示例5:
TEUCHOS_UNIT_TEST(Teuchos_TwoDArrays, emptyTest){
TwoDArray<int> emptyArray;
TEST_EQUALITY_CONST(emptyArray.getNumRows(), 0)
TEST_EQUALITY_CONST(emptyArray.getNumCols(), 0)
TEST_EQUALITY_CONST(emptyArray.getDataArray().size(), 0)
TEST_ASSERT(emptyArray.isEmpty());
}
示例6:
TEST(arrayTest, getNumCols) {
TwoDArray<int>* i = new TwoDArray<int>(5, 5, 0);
TwoDArray<double>* d = new TwoDArray<int>(5, 10, 0);
TwoDArray<std::string>* s = new TwoDArray<std::string>(5, 19, 0);
i->insert(2, 2, 7);
d->insert(4, 4, 3.145);
s->insert(0, 0, "Hello");
EXPECT_EQ(5, i->getNumCols());
EXPECT_EQ(10, d->getNumCols());
EXPECT_EQ(19, s->getNumCols());
delete i;
delete d;
delete s;
}
示例7: variableColsArray
/**
* Test the TwoDColDependency.
*/
TEUCHOS_UNIT_TEST(Teuchos_Dependencies, testTwoDColDependency){
RCP<ParameterList> My_deplist = RCP<ParameterList>(new ParameterList);
RCP<DependencySheet> depSheet1 =
RCP<DependencySheet>(new DependencySheet);
ParameterList
colNumDepList = My_deplist->sublist(
"2D Col Depdency List", false,
"2D Col Dependecy testing list.");
colNumDepList.set("Num cols", 2, "num cols setter");
TwoDArray<double> variableColsArray(11,3,16.5);
RCP<EnhancedNumberValidator<double> >
varColArrayVali = RCP<EnhancedNumberValidator<double> >(
new EnhancedNumberValidator<double>(10,50,4)
);
colNumDepList.set(
"Variable Col Array", variableColsArray, "variable col array",
RCP<TwoDArrayNumberValidator<double> >(
new TwoDArrayNumberValidator<double>(varColArrayVali)));
RCP<TwoDColDependency<int, double> >
arrayColDep = rcp(
new TwoDColDependency<int, double>(
colNumDepList.getEntryRCP("Num cols"),
colNumDepList.getEntryRCP("Variable Col Array") ,
rcp(new AdditionFunction<int>(1))
)
);
depSheet1->addDependency(arrayColDep);
TwoDArray<double> curArray =
colNumDepList.get<TwoDArray<double> >("Variable Col Array");
TEST_EQUALITY_CONST(curArray.getNumCols(),3);
colNumDepList.set("Num cols", 4);
arrayColDep()->evaluate();
curArray =
colNumDepList.get<TwoDArray<double> >("Variable Col Array");
TEST_EQUALITY_CONST(curArray.getNumCols(),5);
colNumDepList.set("Num cols", -2);
TEST_THROW(arrayColDep()->evaluate(),
Exceptions::InvalidParameterValue);
}
示例8:
std::string TwoDArray<T>::toString(const TwoDArray<T> array){
std::stringstream numColsStream;
std::stringstream numRowsStream;
numColsStream << array.getNumCols();
numRowsStream << array.getNumRows();
std::string metaSeperator = TwoDArray<T>::getMetaSeperator();
return
numRowsStream.str() +
TwoDArray<T>::getDimensionsDelimiter() +
numColsStream.str() +
metaSeperator +
(array.isSymmetrical() ? "sym"+metaSeperator : "") +
array.getDataArray().toString();
}
示例9: main
int main() {
TwoDArray<int>* victim = new TwoDArray<int>(5,10,0);
for(int i = 0; i<victim->getNumRows(); i++) {
for(int j = 0; j<victim->getNumCols(); j++) {
victim->insert(i,j,i+j);
}
}
victim->print();
delete victim;
TwoDArray<std::string>* victim2 = new TwoDArray<std::string>(3,2,"moo");
victim2->print();
delete victim2;
return 0;
}