init_auxmem.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2015 Conrad Sanderson (http://conradsanderson.id.au)
  2. // Copyright 2015 National ICT Australia (NICTA)
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // ------------------------------------------------------------------------
  15. #include <armadillo>
  16. #include "catch.hpp"
  17. using namespace arma;
  18. TEST_CASE("init_auxmem_1")
  19. {
  20. double data[] = { 1, 2, 3, 4, 5, 6 };
  21. mat A(data, 2, 3);
  22. mat B(data, 2, 3, false);
  23. mat C(data, 2, 3, false, true);
  24. REQUIRE( A(0,0) == double(1) );
  25. REQUIRE( A(1,0) == double(2) );
  26. REQUIRE( A(0,1) == double(3) );
  27. REQUIRE( A(1,1) == double(4) );
  28. REQUIRE( A(0,2) == double(5) );
  29. REQUIRE( A(1,2) == double(6) );
  30. A(0,0) = 123.0; REQUIRE( data[0] == 1 );
  31. B(0,0) = 123.0; REQUIRE( data[0] == 123.0 );
  32. REQUIRE_THROWS( C.set_size(5,6) );
  33. }