"Fossies" - the Fresh Open Source Software Archive

Member "armadillo-9.800.3/tests/fn_find_finite.cpp" (16 Jun 2016, 1478 Bytes) of package /linux/misc/armadillo-9.800.3.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    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 
   16 
   17 #include <armadillo>
   18 #include "catch.hpp"
   19 
   20 using namespace arma;
   21 
   22 
   23 TEST_CASE("fn_find_finite_1")
   24   {
   25   mat A = 
   26     "\
   27      0.061198   0.201990   0.019678  -0.493936  -0.126745   0.051408;\
   28      0.437242   0.058956  -0.149362  -0.045465   0.296153   0.035437;\
   29     -0.492474  -0.031309   0.314156   0.419733   0.068317  -0.454499;\
   30      0.336352   0.411541   0.458476  -0.393139  -0.135040   0.373833;\
   31      0.239585  -0.428913  -0.406953  -0.291020  -0.353768   0.258704;\
   32     ";
   33   
   34   mat B = A;
   35   
   36   B( 6) =  datum::nan;
   37   B( 8) =  datum::inf;
   38   B(10) = -datum::inf;
   39   
   40   REQUIRE( accu(A.elem(find_finite(A))) == Approx(+0.240136) );
   41   REQUIRE( accu(B.elem(find_finite(B))) == Approx(-0.250039) );
   42   
   43   // REQUIRE_THROWS(  );
   44   }