28 using Teuchos::ArrayRCP;
36 typedef double value_t;
37 typedef float different_value_t;
45 ArrayRCP<value_t> input1(
new value_t [12], 0, 12,
true);
46 for (
int i=0; i < 12; i++)
47 input1[i] = (i+1) * 5;
49 RCP<stridedInput_t> s1;
52 s1 = rcp<stridedInput_t>(
new stridedInput_t(input1, 1));
54 catch (std::exception &e){
59 std::cout << std::endl;
60 std::cout <<
"Test 1, input: " << input1 << std::endl;
61 std::cout <<
"[] test: ";
62 for (
int i=0; i < 12; i++)
63 std::cout << (*s1)[i] <<
" ";
64 std::cout << std::endl;
66 ArrayRCP<const value_t> fromS1;
67 s1->getInputArray(fromS1);
68 std::cout <<
"getInputArray test: ";
69 for (
int i=0; i < 12; i++)
70 std::cout << fromS1[i] <<
" ";
71 std::cout << std::endl;
73 stridedInput_t s1Copy;
76 std::cout <<
"assignment operator test: ";
77 for (
int i=0; i < 12; i++)
78 std::cout << s1Copy[i] <<
" ";
79 std::cout << std::endl;
82 ArrayRCP<const different_value_t> fromS1too;
83 s1->getInputArray(fromS1too);
84 std::cout <<
"getInputArray test -- different type: ";
85 for (
int i=0; i < 12; i++)
86 std::cout << fromS1too[i] <<
" ";
87 std::cout << std::endl;
92 ArrayRCP<value_t> input2(
new value_t [12], 0, 12,
true);
93 for (
int i=0; i < 12; i+=3)
94 input2[i] = (i+1) * -5.0;
96 RCP<stridedInput_t> s2;
99 s2 = rcp<stridedInput_t>(
new stridedInput_t(input2, 3));
101 catch (std::exception &e){
106 std::cout << std::endl;
107 std::cout <<
"Test 2, input: " << input2 << std::endl;
108 std::cout <<
"[] test: ";
109 for (
int i=0; i < 4; i++)
110 std::cout << (*s2)[i] <<
" ";
111 std::cout << std::endl;
113 ArrayRCP<const value_t> fromS2;
114 s2->getInputArray(fromS2);
115 std::cout <<
"getInputArray test: ";
116 for (
int i=0; i < 4; i++)
117 std::cout << fromS2[i] <<
" ";
118 std::cout << std::endl;
120 stridedInput_t s2Copy;
123 std::cout <<
"assignment operator test: ";
124 for (
int i=0; i < 4; i++)
125 std::cout << s2Copy[i] <<
" ";
126 std::cout << std::endl;
129 ArrayRCP<const different_value_t> fromS2too;
130 s1->getInputArray(fromS2too);
131 std::cout <<
"getInputArray test -- different type: ";
132 for (
int i=0; i < 4; i++)
133 std::cout << fromS2too[i] <<
" ";
134 std::cout << std::endl;
137 int main(
int narg,
char *arg[])
139 Tpetra::ScopeGuard tscope(&narg, &arg);
140 Teuchos::RCP<const Teuchos::Comm<int> > tcomm = Tpetra::getDefaultComm();
145 if (tcomm->getRank() > 0)
148 Teuchos::SerialComm<int> comm;
152 std::cout <<
"PASS" << std::endl;
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
int main(int narg, char **arg)
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.