43 #include "Teuchos_Assert.hpp"
45 template <
typename ordinal_type,
typename value_type>
52 template <
typename ordinal_type,
typename value_type>
58 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
true, std::logic_error,
59 "You can't call add_term() after calling fillComplete()!");
62 kji_data[k][
j][i] = c;
63 ikj_data[i][k][
j] = c;
66 template <
typename ordinal_type,
typename value_type>
72 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
true, std::logic_error,
73 "You can't call sum_term() after calling fillComplete()!");
76 kji_data[k][
j][i] += c;
77 ikj_data[i][k][
j] += c;
80 template <
typename ordinal_type,
typename value_type>
88 ikj_array.resize(ikj_data.size());
90 for (
typename ikj_map::const_iterator i_it = ikj_data.begin();
91 i_it != ikj_data.end(); ++i_it) {
92 ikj_array.indices[n] = i_it->first;
93 ikj_array.values[n].resize(i_it->second.size());
95 for (
typename kj_map::const_iterator k_it = i_it->second.begin();
96 k_it != i_it->second.end(); ++k_it) {
97 ikj_array.values[n].indices[l] = k_it->first;
98 ikj_array.values[n].values[l].resize(k_it->second.size());
100 for (
typename j_map::const_iterator j_it = k_it->second.begin();
101 j_it != k_it->second.end(); ++j_it) {
102 ikj_array.values[n].values[l].indices[m] = j_it->first;
103 ikj_array.values[n].values[l].values[m] = j_it->second;
111 kji_array.resize(kji_data.size());
113 for (
typename kji_map::const_iterator k_it = kji_data.begin();
114 k_it != kji_data.end(); ++k_it) {
115 kji_array.indices[n] = k_it->first;
116 kji_array.values[n].resize(k_it->second.size());
118 for (
typename ji_map::const_iterator j_it = k_it->second.begin();
119 j_it != k_it->second.end(); ++j_it) {
120 kji_array.values[n].indices[l] = j_it->first;
121 kji_array.values[n].values[l].resize(j_it->second.size());
123 for (
typename i_map::const_iterator i_it = j_it->second.begin();
124 i_it != j_it->second.end(); ++i_it) {
125 kji_array.values[n].values[l].indices[m] = i_it->first;
126 kji_array.values[n].values[l].values[m] = i_it->second;
137 fill_completed =
true;
140 template <
typename ordinal_type,
typename value_type>
145 return fill_completed;
148 template <
typename ordinal_type,
typename value_type>
151 print(std::ostream& os)
const
154 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
155 "You must call fillComplete() before calling print()!");
161 os <<
"k = " << index(k)
162 <<
", j = " << index(
j)
163 <<
", i = " << index(i)
164 <<
", Cijk = " << value(i) << std::endl;
167 template <
typename ordinal_type,
typename value_type>
173 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
174 "You must call fillComplete() before calling getValue()!");
182 if (j_it == j_end(k_it))
186 if (i_it == i_end(j_it))
192 template <
typename ordinal_type,
typename value_type>
198 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
199 "You must call fillComplete() before calling num_entries()!");
203 for (
k_iterator k = k_begin(); k != k_end(); ++k)
211 template <
typename ordinal_type,
typename value_type>
217 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
218 "You must call fillComplete() before calling num_k()!");
220 return kji_array.size();
223 template <
typename ordinal_type,
typename value_type>
229 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
230 "You must call fillComplete() before calling num_j()!");
233 return k.
value().size();
236 template <
typename ordinal_type,
typename value_type>
242 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
243 "You must call fillComplete() before calling num_i()!");
245 return j.value().size();
248 template <
typename ordinal_type,
typename value_type>
254 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
255 "You must call fillComplete() before calling find_k()!");
257 return kji_array.find(k);
260 template <
typename ordinal_type,
typename value_type>
266 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
267 "You must call fillComplete() before calling find_j()!");
272 template <
typename ordinal_type,
typename value_type>
278 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
279 "You must call fillComplete() before calling find_i()!");
281 return j.value().find(i);
284 template <
typename ordinal_type,
typename value_type>
290 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
291 "You must call fillComplete() before calling k_begin()!");
293 return kji_array.begin();
296 template <
typename ordinal_type,
typename value_type>
302 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
303 "You must call fillComplete() before calling k_end()!");
305 return kji_array.end();
308 template <
typename ordinal_type,
typename value_type>
314 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
315 "You must call fillComplete() before calling k_rbegin()!");
317 return kji_array.rbegin();
320 template <
typename ordinal_type,
typename value_type>
326 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
327 "You must call fillComplete() before calling k_rend()!");
329 return kji_array.rend();
332 template <
typename ordinal_type,
typename value_type>
338 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
339 "You must call fillComplete() before calling j_begin()!");
341 return k.
value().begin();
344 template <
typename ordinal_type,
typename value_type>
350 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
351 "You must call fillComplete() before calling j_end()!");
353 return k.
value().end();
356 template <
typename ordinal_type,
typename value_type>
362 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
363 "You must call fillComplete() before calling j_begin()!");
365 return k.
value().begin();
368 template <
typename ordinal_type,
typename value_type>
374 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
375 "You must call fillComplete() before calling j_end()!");
377 return k.
value().end();
380 template <
typename ordinal_type,
typename value_type>
386 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
387 "You must call fillComplete() before calling i_begin()!");
389 return j.value().begin();
392 template <
typename ordinal_type,
typename value_type>
398 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
399 "You must call fillComplete() before calling i_end()!");
401 return j.value().end();
404 template <
typename ordinal_type,
typename value_type>
410 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
411 "You must call fillComplete() before calling num_i()!");
413 return ikj_array.size();
416 template <
typename ordinal_type,
typename value_type>
422 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
423 "You must call fillComplete() before calling num_k()!");
425 return i.
value().size();
428 template <
typename ordinal_type,
typename value_type>
431 num_j(
const ik_iterator& k)
const
434 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
435 "You must call fillComplete() before calling num_j()!");
437 return k.value().size();
440 template <
typename ordinal_type,
typename value_type>
446 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
447 "You must call fillComplete() before calling find_i()!");
449 return ikj_array.find(i);
452 template <
typename ordinal_type,
typename value_type>
458 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
459 "You must call fillComplete() before calling find_k()!");
461 return i.
value().find(k);
464 template <
typename ordinal_type,
typename value_type>
470 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
471 "You must call fillComplete() before calling find_j()!");
473 return k.value().find(
j);
476 template <
typename ordinal_type,
typename value_type>
482 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
483 "You must call fillComplete() before calling i_begin()!");
485 return ikj_array.begin();
488 template <
typename ordinal_type,
typename value_type>
494 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
495 "You must call fillComplete() before calling i_end()!");
497 return ikj_array.end();
500 template <
typename ordinal_type,
typename value_type>
506 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
507 "You must call fillComplete() before calling i_rbegin()!");
509 return ikj_array.rbegin();
512 template <
typename ordinal_type,
typename value_type>
518 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
519 "You must call fillComplete() before calling i_rend()!");
521 return ikj_array.rend();
524 template <
typename ordinal_type,
typename value_type>
530 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
531 "You must call fillComplete() before calling k_begin()!");
533 return i.
value().begin();
536 template <
typename ordinal_type,
typename value_type>
542 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
543 "You must call fillComplete() before calling k_end()!");
545 return i.
value().end();
548 template <
typename ordinal_type,
typename value_type>
554 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
555 "You must call fillComplete() before calling k_begin()!");
557 return i.
value().begin();
560 template <
typename ordinal_type,
typename value_type>
566 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
567 "You must call fillComplete() before calling k_end()!");
569 return i.
value().end();
572 template <
typename ordinal_type,
typename value_type>
575 j_begin(
const ik_iterator& k)
const
578 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
579 "You must call fillComplete() before calling j_begin()!");
581 return k.value().begin();
584 template <
typename ordinal_type,
typename value_type>
587 j_end(
const ik_iterator& k)
const
590 TEUCHOS_TEST_FOR_EXCEPTION(fill_completed ==
false, std::logic_error,
591 "You must call fillComplete() before calling j_end()!");
593 return k.value().end();