当前位置: 首页>>代码示例>>C++>>正文


C++ TwoDArray::getNumRows方法代码示例

本文整理汇总了C++中TwoDArray::getNumRows方法的典型用法代码示例。如果您正苦于以下问题:C++ TwoDArray::getNumRows方法的具体用法?C++ TwoDArray::getNumRows怎么用?C++ TwoDArray::getNumRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TwoDArray的用法示例。


在下文中一共展示了TwoDArray::getNumRows方法的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);

}
开发者ID:00liujj,项目名称:trilinos,代码行数:32,代码来源:TwoDArray_UnitTests.cpp

示例2:

TEST(TwoDArrayRow, NumRow) {
    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->getNumRows());
    delete tDInt;
    EXPECT_EQ(11, tDDouble->getNumRows());
    delete tDDouble;
    EXPECT_EQ(12, tDString->getNumRows());
    delete tDString;
}
开发者ID:GregGay,项目名称:csci333_Project2,代码行数:12,代码来源:TwoDArray.cpp

示例3:

TEST(TwoDArray, GetNumRows) {
	TwoDArray<int>* newArray = new TwoDArray<int>(7,8,0);
	EXPECT_EQ(8, newArray->getNumRows());
	delete newArray;

	TwoDArray<double>* newDouble = new TwoDArray<double>(80,80,0.0);
	EXPECT_EQ(80, newDouble->getNumRows());
	delete newDouble;

	TwoDArray<std::string>* newString = new TwoDArray<std::string>(49,78,"hi");
	EXPECT_EQ(78, newString->getNumRows());
	delete newString;
}
开发者ID:billymills,项目名称:sparse-array-api,代码行数:13,代码来源:Sparse.cpp

示例4:

TEST(numRows, stringTest) {
    int r = 10;
    int c = 5;
    TwoDArray<string>* a = new TwoDArray<string>(r, c);
    EXPECT_EQ(10, a->getNumRows());
    delete a;
}
开发者ID:aviindub,项目名称:TwoDArray,代码行数:7,代码来源:TwoDArray.cpp

示例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());
}
开发者ID:00liujj,项目名称:trilinos,代码行数:7,代码来源:TwoDArray_UnitTests.cpp

示例6:

TEST(arrayTest, getNumRows) {
  TwoDArray<int>* i = new TwoDArray<int>(5, 5, 0);
  TwoDArray<double>* d = new TwoDArray<int>(6, 5, 0);
  TwoDArray<std::string>* s = new TwoDArray<std::string>(10, 5, "o");

  i->insert(2, 2, 7);
  d->insert(4, 4, 3.145);
  s->insert(0, 0, "Hello");

  EXPECT_EQ(5, i->getNumRows());
  EXPECT_EQ(6, d->getNumRows());
  EXPECT_EQ(10, s->getNumRows());

  delete i;
  delete d;
  delete s;
}
开发者ID:hcsnyder,项目名称:csci333-Project2,代码行数:17,代码来源:Array_test.cpp

示例7: variableRowsArray

/**
 * Test the TwoDRowDependency.
 */
TEUCHOS_UNIT_TEST(Teuchos_Dependencies, testTwoDRowDependency){
	RCP<ParameterList> My_deplist = RCP<ParameterList>(new ParameterList);
	RCP<DependencySheet> depSheet1 =
    RCP<DependencySheet>(new DependencySheet);

	ParameterList
	rowNumDepList = My_deplist->sublist(
    "2D Row Depdency List", false,
    "2D Row Dependecy testing list.");
	rowNumDepList.set("Num rows", 10, "num rows setter");
  TwoDArray<double> variableRowsArray(11,2,16.5);
	RCP<EnhancedNumberValidator<double> >
	varRowArrayVali = RCP<EnhancedNumberValidator<double> >(
  		new EnhancedNumberValidator<double>(10,50,4)
	);
	rowNumDepList.set(
    "Variable Row Array", variableRowsArray, "variable row array",
	  RCP<TwoDArrayNumberValidator<double> >(
      new TwoDArrayNumberValidator<double>(varRowArrayVali)));

	RCP<TwoDRowDependency<int, double> >
	  arrayRowDep = rcp(
  		new TwoDRowDependency<int, double>(
		  rowNumDepList.getEntryRCP("Num rows"),
			rowNumDepList.getEntryRCP("Variable Row Array") ,
      rcp(new AdditionFunction<int>(1))
		)
	);
	depSheet1->addDependency(arrayRowDep);
  TwoDArray<double> curArray =
    rowNumDepList.get<TwoDArray<double> >("Variable Row Array");
	TEST_EQUALITY_CONST(curArray.getNumRows(),11);
	rowNumDepList.set("Num rows", 12);
	arrayRowDep()->evaluate();
  curArray =
    rowNumDepList.get<TwoDArray<double> >("Variable Row Array");
	TEST_EQUALITY_CONST(curArray.getNumRows(),13);
	rowNumDepList.set("Num rows", -2);
	TEST_THROW(arrayRowDep()->evaluate(),
    Exceptions::InvalidParameterValue);
}
开发者ID:OpenModelica,项目名称:OMCompiler-3rdParty,代码行数:44,代码来源:Dependencies_UnitTests.cpp

示例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();
}
开发者ID:OpenModelica,项目名称:OMCompiler-3rdParty,代码行数:14,代码来源:Teuchos_TwoDArray.hpp

示例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;
}
开发者ID:Derbs,项目名称:CSCI333-Project2,代码行数:14,代码来源:test.cpp


注:本文中的TwoDArray::getNumRows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。