attributes.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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("attributes_1")
  19. {
  20. mat A(5,6);
  21. REQUIRE(A.n_rows == 5);
  22. REQUIRE(A.n_cols == 6);
  23. REQUIRE(A.n_elem == 30);
  24. vec B(5);
  25. REQUIRE(B.n_rows == 5);
  26. REQUIRE(B.n_cols == 1);
  27. REQUIRE(B.n_elem == 5);
  28. rowvec C(6);
  29. REQUIRE(C.n_rows == 1);
  30. REQUIRE(C.n_cols == 6);
  31. REQUIRE(C.n_elem == 6);
  32. cube D(5,6,2);
  33. REQUIRE(D.n_rows == 5);
  34. REQUIRE(D.n_cols == 6);
  35. REQUIRE(D.n_slices == 2);
  36. REQUIRE(D.n_elem == 60);
  37. sp_mat E(50,60);
  38. E(0,0) = 1.0;
  39. E(E.n_rows-1,E.n_cols-1) = 1.0;
  40. REQUIRE(E.n_rows == 50);
  41. REQUIRE(E.n_cols == 60);
  42. REQUIRE(E.n_elem == 3000);
  43. REQUIRE(E.n_nonzero == 2);
  44. field<mat> G(5,6,2);
  45. REQUIRE(G.n_rows == 5);
  46. REQUIRE(G.n_cols == 6);
  47. REQUIRE(G.n_slices == 2);
  48. REQUIRE(G.n_elem == 60);
  49. }