63 using Teuchos::ArrayRCP;
79 ArrayRCP<value_t> input1(
new value_t [12], 0, 12,
true);
80 for (
int i=0; i < 12; i++)
81 input1[i] = (i+1) * 5;
83 RCP<stridedInput_t> s1;
86 s1 = rcp<stridedInput_t>(
new stridedInput_t(input1, 1));
88 catch (std::exception &e){
92 std::cout << std::endl;
93 std::cout <<
"Test 1, input: " << input1 << std::endl;
94 std::cout <<
"[] test: ";
95 for (
int i=0; i < 12; i++)
96 std::cout << (*s1)[i] <<
" ";
97 std::cout << std::endl;
99 ArrayRCP<const value_t> fromS1;
100 s1->getInputArray(fromS1);
101 std::cout <<
"getInputArray test: ";
102 for (
int i=0; i < 12; i++)
103 std::cout << fromS1[i] <<
" ";
104 std::cout << std::endl;
106 stridedInput_t s1Copy;
109 std::cout <<
"assignment operator test: ";
110 for (
int i=0; i < 12; i++)
111 std::cout << s1Copy[i] <<
" ";
112 std::cout << std::endl;
117 ArrayRCP<value_t> input2(
new value_t [12], 0, 12,
true);
118 for (
int i=0; i < 12; i+=3)
119 input2[i] = (i+1) * -5.0;
121 RCP<stridedInput_t> s2;
124 s2 = rcp<stridedInput_t>(
new stridedInput_t(input2, 3));
126 catch (std::exception &e){
130 std::cout << std::endl;
131 std::cout <<
"Test 2, input: " << input2 << std::endl;
132 std::cout <<
"[] test: ";
133 for (
int i=0; i < 4; i++)
134 std::cout << (*s2)[i] <<
" ";
135 std::cout << std::endl;
137 ArrayRCP<const value_t> fromS2;
138 s2->getInputArray(fromS2);
139 std::cout <<
"getInputArray test: ";
140 for (
int i=0; i < 4; i++)
141 std::cout << fromS2[i] <<
" ";
142 std::cout << std::endl;
144 stridedInput_t s2Copy;
147 std::cout <<
"assignment operator test: ";
148 for (
int i=0; i < 4; i++)
149 std::cout << s2Copy[i] <<
" ";
150 std::cout << std::endl;
153 int main(
int argc,
char *argv[])
155 Teuchos::GlobalMPISession session(&argc, &argv);
156 Teuchos::RCP<const Teuchos::Comm<int> > comm =
157 Teuchos::DefaultComm<int>::getComm();
159 if (comm->getRank() > 0)
164 std::cout <<
"PASS" << std::endl;
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
common code used by tests
void StridedDataTest(Teuchos::RCP< const Teuchos::Comm< int > > &comm)
The StridedData class manages lists of weights or coordinates.
int main(int argc, char *argv[])
This file defines the StridedData class.