fn_conj.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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("fn_conj_1")
  19. {
  20. vec re = linspace<vec>(1,5,6);
  21. vec im = 2*linspace<vec>(1,5,6);
  22. cx_vec a = cx_vec(re,im);
  23. cx_vec b = conj(a);
  24. REQUIRE( accu(abs(real(b) - ( re))) == Approx(0.0) );
  25. REQUIRE( accu(abs(imag(b) - (-im))) == Approx(0.0) );
  26. }
  27. TEST_CASE("fn_conj2")
  28. {
  29. cx_mat A = randu<cx_mat>(5,6);
  30. cx_mat B = conj(A);
  31. REQUIRE( all(vectorise(real(B) == real(A))) == true );
  32. REQUIRE( all(vectorise(imag(B) == -imag(A))) == true );
  33. }