63 using Teuchos::ArrayRCP;
71 typedef double value_t;
72 typedef float different_value_t;
80 ArrayRCP<value_t> input1(
new value_t [12], 0, 12,
true);
81 for (
int i=0; i < 12; i++)
82 input1[i] = (i+1) * 5;
84 RCP<stridedInput_t> s1;
87 s1 = rcp<stridedInput_t>(
new stridedInput_t(input1, 1));
89 catch (std::exception &e){
94 std::cout << std::endl;
95 std::cout <<
"Test 1, input: " << input1 << std::endl;
96 std::cout <<
"[] test: ";
97 for (
int i=0; i < 12; i++)
98 std::cout << (*s1)[i] <<
" ";
99 std::cout << std::endl;
101 ArrayRCP<const value_t> fromS1;
102 s1->getInputArray(fromS1);
103 std::cout <<
"getInputArray test: ";
104 for (
int i=0; i < 12; i++)
105 std::cout << fromS1[i] <<
" ";
106 std::cout << std::endl;
108 stridedInput_t s1Copy;
111 std::cout <<
"assignment operator test: ";
112 for (
int i=0; i < 12; i++)
113 std::cout << s1Copy[i] <<
" ";
114 std::cout << std::endl;
117 ArrayRCP<const different_value_t> fromS1too;
118 s1->getInputArray(fromS1too);
119 std::cout <<
"getInputArray test -- different type: ";
120 for (
int i=0; i < 12; i++)
121 std::cout << fromS1too[i] <<
" ";
122 std::cout << std::endl;
127 ArrayRCP<value_t> input2(
new value_t [12], 0, 12,
true);
128 for (
int i=0; i < 12; i+=3)
129 input2[i] = (i+1) * -5.0;
131 RCP<stridedInput_t> s2;
134 s2 = rcp<stridedInput_t>(
new stridedInput_t(input2, 3));
136 catch (std::exception &e){
141 std::cout << std::endl;
142 std::cout <<
"Test 2, input: " << input2 << std::endl;
143 std::cout <<
"[] test: ";
144 for (
int i=0; i < 4; i++)
145 std::cout << (*s2)[i] <<
" ";
146 std::cout << std::endl;
148 ArrayRCP<const value_t> fromS2;
149 s2->getInputArray(fromS2);
150 std::cout <<
"getInputArray test: ";
151 for (
int i=0; i < 4; i++)
152 std::cout << fromS2[i] <<
" ";
153 std::cout << std::endl;
155 stridedInput_t s2Copy;
158 std::cout <<
"assignment operator test: ";
159 for (
int i=0; i < 4; i++)
160 std::cout << s2Copy[i] <<
" ";
161 std::cout << std::endl;
164 ArrayRCP<const different_value_t> fromS2too;
165 s1->getInputArray(fromS2too);
166 std::cout <<
"getInputArray test -- different type: ";
167 for (
int i=0; i < 4; i++)
168 std::cout << fromS2too[i] <<
" ";
169 std::cout << std::endl;
172 int main(
int narg,
char *arg[])
174 Tpetra::ScopeGuard tscope(&narg, &arg);
175 Teuchos::RCP<const Teuchos::Comm<int> > tcomm = Tpetra::getDefaultComm();
180 if (tcomm->getRank() > 0)
183 Teuchos::SerialComm<int> comm;
187 std::cout <<
"PASS" << std::endl;
int main(int narg, char *arg[])
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
common code used by tests
The StridedData class manages lists of weights or coordinates.
void StridedDataTest(const Teuchos::SerialComm< int > &comm)
This file defines the StridedData class.