示例#1
0
void test_vectorization_logic()
{

#ifdef EIGEN_VECTORIZE

  CALL_SUBTEST( vectorization_logic<int>::run() );
  CALL_SUBTEST( vectorization_logic<float>::run() );
  CALL_SUBTEST( vectorization_logic<double>::run() );
  CALL_SUBTEST( vectorization_logic<std::complex<float> >::run() );
  CALL_SUBTEST( vectorization_logic<std::complex<double> >::run() );
  
  if(internal::packet_traits<float>::Vectorizable)
  {
    VERIFY(test_assign(Matrix<float,3,3>(),Matrix<float,3,3>()+Matrix<float,3,3>(),
      LinearTraversal,CompleteUnrolling));
      
    VERIFY(test_redux(Matrix<float,5,2>(),
      DefaultTraversal,CompleteUnrolling));
  }
  
  if(internal::packet_traits<double>::Vectorizable)
  {
    VERIFY(test_assign(Matrix<double,3,3>(),Matrix<double,3,3>()+Matrix<double,3,3>(),
      LinearTraversal,CompleteUnrolling));
    
    VERIFY(test_redux(Matrix<double,7,3>(),
      DefaultTraversal,CompleteUnrolling));
  }
#endif // EIGEN_VECTORIZE

}
示例#2
0
static int
run_test (int /*unused*/, char* /*unused*/ [])
{
    test_simple_throw ();

    // constructors
    test_size_ctor ();
    test_npos_ctor ();

    test_max_size_ctor1 ();
    test_max_size_ctor2 ();

    test_len_ctor ();

    // member functions
    test_resize ();
    test_reserve ();
    test_at ();
    test_append ();
    test_assign ();

    test_insert1 ();
    test_insert2 ();

    test_erase ();

    test_replace1 ();
    test_replace2 ();
    test_replace3 ();

    test_copy ();
    test_substr ();

    return 0;
}
示例#3
0
void test_leak () {                             // test memory leak.
  for (;;) {                                    // use top4.1 to watch memory usage
    test_constructor();
    test_assign();
    test_conversion_deref();
    test_bind_cmp();
    test_use();
    test_cycle();
  }
}
int run_test (int, char*[])
{
    if (rw_enabled ("char"))
        test_assign (char (), "char");
    else
        rw_note (0, __FILE__, __LINE__, "char test disabled");

#ifndef _RWSTD_NO_WCHAR_T

    if (rw_enabled ("wchar_t"))
        test_assign (wchar_t (), "wchar_t");
    else
        rw_note (0, __FILE__, __LINE__, "wchar_t test disabled");

#endif   // _RWSTD_NO_WCHAR_T

    return 0;

}
示例#5
0
int main(void)
{
  int i, strict;
  //  srand(time(NULL));
  srand(0);
  intdim = 0;
  /*for (intdim=1;intdim<2;intdim++) {*/

  for (strict=0;strict<2;strict++) {
    /* init */
    pk = pk_manager_alloc(strict);
    ppl = ap_ppl_poly_manager_alloc(strict);
    for (i=0;i<AP_EXC_SIZE;i++){
      pk->option.abort_if_exception[i] = true;
      ppl->option.abort_if_exception[i] = true;
    }
    
    printf("\n\ncomparing libraries:\n- %s (%s)\n- %s (%s)\nwith strict=%i int=%i\n\n",
	   pk->library,pk->version,ppl->library,ppl->version,strict,intdim);
    /* run tests */
    test_conv();
    test_join();
    test_meet();
    test_join_array();
    test_meet_array();
    test_dimadd();
    test_dimrem();
    test_forget();
    test_permute();
    test_expand();
    test_fold();
    test_add_lincons();
    test_add_ray();
    test_box();
    test_vbound();
    test_lbound();
    test_csat();
    test_isat();
    test_assign();
    test_par_assign();
    test_subst();
    test_par_subst();
    if (!strict) test_widen(); // behave differently in strict mode
   
    /* clean-up */
    ap_manager_free(pk);
    ap_manager_free(ppl);
  }

  /*}*/

  if (error_) printf("\n%i error(s)!\n",error_);
  else printf("\nall tests passed\n");
  return 0;
}
示例#6
0
void test_assign (charT*, Traits*, Allocator*,
                  const StringTestCaseData<charT> &tdata)
{
    typedef std::basic_string<charT, Traits, Allocator> String;

    if (tdata.func_.which_ == Assign (range)) {

        switch (tdata.func_.iter_id_) {

        // exercise possible overloads of the member function template
        // on common RandomAccessIterator types
#undef TEST
#define TEST(Iterator) do {                                                 \
        typedef typename String::Iterator Iter;                             \
        static const                                                        \
        AssignRangeOverload<String, Iter> rng;                              \
        test_assign ((charT*)0, (Traits*)0, (Allocator*)0, rng, tdata);     \
    } while (0)

        case StringIds::Pointer: TEST (pointer); break;
        case StringIds::ConstPointer: TEST (const_pointer); break;
        case StringIds::Iterator: TEST (iterator); break;
        case StringIds::ConstIterator: TEST (const_iterator); break;

        case StringIds::ReverseIterator: TEST (reverse_iterator); break;
        case StringIds::ConstReverseIterator: TEST (const_reverse_iterator);
            break;

        // exercise specializations of the member function template
        // on the required iterator categories

#undef TEST
#define TEST(Iterator) do {                                                 \
        typedef Iterator<charT> Iter;                                       \
        static const                                                        \
        AssignRange<String, Iter> rng;                                      \
        test_assign ((charT*)0, (Traits*)0, (Allocator*)0, rng, tdata);     \
    } while (0)

        case StringIds::Input: TEST (InputIter); break;
        case StringIds::Forward: TEST (ConstFwdIter); break;
        case StringIds::Bidir: TEST (ConstBidirIter); break;
        case StringIds::Random: TEST (ConstRandomAccessIter); break;

        default:
            rw_error (0, 0, __LINE__, "bad iterator id");
        }
    }
    else {
        // exercise ordinary overloads of the member function
        static const RangeBase<String> rng;
        test_assign ((charT*)0, (Traits*)0, (Allocator*)0, rng, tdata);
    }
}
示例#7
0
int 
main()
{
    std::list<int> const data = build_list();
    test_assign(data);
    test_assign2(data);
    test_back(data);
    test_begin(data);
    test_clear(data);
    return boost::report_errors();
}
示例#8
0
int main (void) {
  START("CoolHandle");
  test_constructor();
  test_assign();
  test_conversion_deref();
  test_bind_cmp();
  test_use();
  test_cycle();
#if LEAK
  test_leak();
#endif
  SUMMARY();
  return 0;
}
示例#9
0
文件: Test.c 项目: jens-maus/newsrog
} SDFV
# endif

main (int argc, char *argv[])
{
//   Func1();
   test_allocfree();
   test_member();
   test_nthchild();
// test_clone();
   test_fileio();
   test_assign();
//   test_error();
   test_insert();
// test_notify();
}
示例#10
0
int
main()
{
    std::deque<int> const data = build_deque();
    test_assign(data);
    test_assign2(data);
    test_at(data);
    test_back(data);
    test_begin(data);
    test_clear(data);
    test_front(data);
    test_empty(data);
    test_end(data);
    test_erase(data);
    test_get_allocator(data);
    return boost::report_errors();
}
示例#11
0
int main(int, char**)
{
    {
    typedef test_allocator<char> A;
    typedef std::basic_string<char, std::char_traits<char>, A> S;
    test(S(), A(3));
    test(S("1"), A(5));
    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7));
    }
#if TEST_STD_VER >= 11
    {
    typedef min_allocator<char> A;
    typedef std::basic_string<char, std::char_traits<char>, A> S;
    test(S(), A());
    test(S("1"), A());
    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A());
    }

#ifndef TEST_HAS_NO_EXCEPTIONS
    {
    typedef poca_alloc<char> A;
    typedef std::basic_string<char, std::char_traits<char>, A> S;
    const char * p1 = "This is my first string";
    const char * p2 = "This is my second string";

    alloc_imp imp1;
    alloc_imp imp2;
    S s1(p1, A(&imp1));
    S s2(p2, A(&imp2));

    assert(s1 == p1);
    assert(s2 == p2);

    imp2.deactivate();
    test_assign(s1, s2);
    assert(s1 == p1);
    assert(s2 == p2);
    }
#endif
#endif

  return 0;
}
示例#12
0
  static void run()
  {
    
    typedef Matrix<Scalar,PacketSize,1> Vector1;
    typedef Matrix<Scalar,Dynamic,1> VectorX;
    typedef Matrix<Scalar,Dynamic,Dynamic> MatrixXX;
    typedef Matrix<Scalar,PacketSize,PacketSize> Matrix11;
    typedef Matrix<Scalar,2*PacketSize,2*PacketSize> Matrix22;
    typedef Matrix<Scalar,(Matrix11::Flags&RowMajorBit)?16:4*PacketSize,(Matrix11::Flags&RowMajorBit)?4*PacketSize:16> Matrix44;
    typedef Matrix<Scalar,(Matrix11::Flags&RowMajorBit)?16:4*PacketSize,(Matrix11::Flags&RowMajorBit)?4*PacketSize:16,DontAlign|EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION> Matrix44u;
    typedef Matrix<Scalar,4*PacketSize,4*PacketSize,ColMajor> Matrix44c;
    typedef Matrix<Scalar,4*PacketSize,4*PacketSize,RowMajor> Matrix44r;

    typedef Matrix<Scalar,
        (PacketSize==8 ? 4 : PacketSize==4 ? 2 : PacketSize==2 ? 1 : /*PacketSize==1 ?*/ 1),
        (PacketSize==8 ? 2 : PacketSize==4 ? 2 : PacketSize==2 ? 2 : /*PacketSize==1 ?*/ 1)
      > Matrix1;

    typedef Matrix<Scalar,
        (PacketSize==8 ? 4 : PacketSize==4 ? 2 : PacketSize==2 ? 1 : /*PacketSize==1 ?*/ 1),
        (PacketSize==8 ? 2 : PacketSize==4 ? 2 : PacketSize==2 ? 2 : /*PacketSize==1 ?*/ 1),
      DontAlign|((Matrix1::Flags&RowMajorBit)?RowMajor:ColMajor)> Matrix1u;

    // this type is made such that it can only be vectorized when viewed as a linear 1D vector
    typedef Matrix<Scalar,
        (PacketSize==8 ? 4 : PacketSize==4 ? 6 : PacketSize==2 ? ((Matrix11::Flags&RowMajorBit)?2:3) : /*PacketSize==1 ?*/ 1),
        (PacketSize==8 ? 6 : PacketSize==4 ? 2 : PacketSize==2 ? ((Matrix11::Flags&RowMajorBit)?3:2) : /*PacketSize==1 ?*/ 3)
      > Matrix3;
    
    #if !EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT
    VERIFY(test_assign(Vector1(),Vector1(),
      InnerVectorizedTraversal,CompleteUnrolling));
    VERIFY(test_assign(Vector1(),Vector1()+Vector1(),
      InnerVectorizedTraversal,CompleteUnrolling));
    VERIFY(test_assign(Vector1(),Vector1().cwiseProduct(Vector1()),
      InnerVectorizedTraversal,CompleteUnrolling));
    VERIFY(test_assign(Vector1(),Vector1().template cast<Scalar>(),
      InnerVectorizedTraversal,CompleteUnrolling));


    VERIFY(test_assign(Vector1(),Vector1(),
      InnerVectorizedTraversal,CompleteUnrolling));
    VERIFY(test_assign(Vector1(),Vector1()+Vector1(),
      InnerVectorizedTraversal,CompleteUnrolling));
    VERIFY(test_assign(Vector1(),Vector1().cwiseProduct(Vector1()),
      InnerVectorizedTraversal,CompleteUnrolling));

    VERIFY(test_assign(Matrix44(),Matrix44()+Matrix44(),
      InnerVectorizedTraversal,InnerUnrolling));

    VERIFY(test_assign(Matrix44u(),Matrix44()+Matrix44(),
      LinearTraversal,NoUnrolling));

    VERIFY(test_assign(Matrix1u(),Matrix1()+Matrix1(),
      LinearTraversal,CompleteUnrolling));

    VERIFY(test_assign(Matrix44c().col(1),Matrix44c().col(2)+Matrix44c().col(3),
      InnerVectorizedTraversal,CompleteUnrolling));
    
    VERIFY(test_assign(Matrix44r().row(2),Matrix44r().row(1)+Matrix44r().row(1),
      InnerVectorizedTraversal,CompleteUnrolling));
        
    if(PacketSize>1)
    {
      typedef Matrix<Scalar,3,3,ColMajor> Matrix33c;
      VERIFY(test_assign(Matrix33c().row(2),Matrix33c().row(1)+Matrix33c().row(1),
        LinearTraversal,CompleteUnrolling));
      VERIFY(test_assign(Matrix33c().col(0),Matrix33c().col(1)+Matrix33c().col(1),
        LinearTraversal,CompleteUnrolling));
              
      VERIFY(test_assign(Matrix3(),Matrix3().cwiseQuotient(Matrix3()),
        PacketTraits::HasDiv ? LinearVectorizedTraversal : LinearTraversal,CompleteUnrolling));
        
      VERIFY(test_assign(Matrix<Scalar,17,17>(),Matrix<Scalar,17,17>()+Matrix<Scalar,17,17>(),
        LinearTraversal,NoUnrolling));
        
      VERIFY(test_assign(Matrix11(),Matrix<Scalar,17,17>().template block<PacketSize,PacketSize>(2,3)+Matrix<Scalar,17,17>().template block<PacketSize,PacketSize>(8,4),
        DefaultTraversal,PacketSize>4?InnerUnrolling:CompleteUnrolling));
    }
    
    VERIFY(test_redux(Matrix3(),
      LinearVectorizedTraversal,CompleteUnrolling));

    VERIFY(test_redux(Matrix44(),
      LinearVectorizedTraversal,NoUnrolling));

    VERIFY(test_redux(Matrix44().template block<(Matrix1::Flags&RowMajorBit)?4:PacketSize,(Matrix1::Flags&RowMajorBit)?PacketSize:4>(1,2),
      DefaultTraversal,CompleteUnrolling));

    VERIFY(test_redux(Matrix44c().template block<2*PacketSize,1>(1,2),
      LinearVectorizedTraversal,CompleteUnrolling));

    VERIFY(test_redux(Matrix44r().template block<1,2*PacketSize>(2,1),
      LinearVectorizedTraversal,CompleteUnrolling));

    VERIFY((test_assign<
            Map<Matrix22, Aligned, OuterStride<3*PacketSize> >,
            Matrix22
            >(InnerVectorizedTraversal,CompleteUnrolling)));

    VERIFY((test_assign<
            Map<Matrix<Scalar,EIGEN_PLAIN_ENUM_MAX(2,PacketSize),EIGEN_PLAIN_ENUM_MAX(2,PacketSize)>, Aligned, InnerStride<3*PacketSize> >,
            Matrix<Scalar,EIGEN_PLAIN_ENUM_MAX(2,PacketSize),EIGEN_PLAIN_ENUM_MAX(2,PacketSize)>
            >(DefaultTraversal,CompleteUnrolling)));

    VERIFY((test_assign(Matrix11(), Matrix<Scalar,PacketSize,EIGEN_PLAIN_ENUM_MIN(2,PacketSize)>()*Matrix<Scalar,EIGEN_PLAIN_ENUM_MIN(2,PacketSize),PacketSize>(),
                        InnerVectorizedTraversal, CompleteUnrolling)));
    #endif

    VERIFY(test_assign(MatrixXX(10,10),MatrixXX(20,20).block(10,10,2,3),
      SliceVectorizedTraversal,NoUnrolling));

    VERIFY(test_redux(VectorX(10),
      LinearVectorizedTraversal,NoUnrolling));

    
  }
示例#13
0
void test_vectorization_logic()
{

#ifdef EIGEN_VECTORIZE

#ifdef  EIGEN_DEFAULT_TO_ROW_MAJOR
  VERIFY(test_assign(Vector4f(),Vector4f(),
    LinearVectorization,CompleteUnrolling));
  VERIFY(test_assign(Vector4f(),Vector4f()+Vector4f(),
    LinearVectorization,CompleteUnrolling));
  VERIFY(test_assign(Vector4f(),Vector4f().cwise() * Vector4f(),
    LinearVectorization,CompleteUnrolling));
#else
  VERIFY(test_assign(Vector4f(),Vector4f(),
    InnerVectorization,CompleteUnrolling));
  VERIFY(test_assign(Vector4f(),Vector4f()+Vector4f(),
    InnerVectorization,CompleteUnrolling));
  VERIFY(test_assign(Vector4f(),Vector4f().cwise() * Vector4f(),
    InnerVectorization,CompleteUnrolling));
#endif

  VERIFY(test_assign(Matrix4f(),Matrix4f(),
    InnerVectorization,CompleteUnrolling));
  VERIFY(test_assign(Matrix4f(),Matrix4f()+Matrix4f(),
    InnerVectorization,CompleteUnrolling));
  VERIFY(test_assign(Matrix4f(),Matrix4f().cwise() * Matrix4f(),
    InnerVectorization,CompleteUnrolling));

  VERIFY(test_assign(Matrix<float,16,16>(),Matrix<float,16,16>()+Matrix<float,16,16>(),
    InnerVectorization,InnerUnrolling));

  VERIFY(test_assign(Matrix<float,16,16,DontAlign>(),Matrix<float,16,16>()+Matrix<float,16,16>(),
    NoVectorization,InnerUnrolling));

  VERIFY(test_assign(Matrix<float,6,2>(),Matrix<float,6,2>().cwise() / Matrix<float,6,2>(),
    LinearVectorization,CompleteUnrolling));

  VERIFY(test_assign(Matrix<float,17,17>(),Matrix<float,17,17>()+Matrix<float,17,17>(),
    NoVectorization,InnerUnrolling));

  VERIFY(test_assign(Matrix<float,4,4>(),Matrix<float,17,17>().block<4,4>(2,3)+Matrix<float,17,17>().block<4,4>(10,4),
    NoVectorization,CompleteUnrolling));

  VERIFY(test_assign(MatrixXf(10,10),MatrixXf(20,20).block(10,10,2,3),
    SliceVectorization,NoUnrolling));

  VERIFY(test_assign(VectorXf(10),VectorXf(10)+VectorXf(10),
    LinearVectorization,NoUnrolling));

  VERIFY(test_sum(VectorXf(10),
    LinearVectorization,NoUnrolling));

  VERIFY(test_sum(Matrix<float,5,2>(),
    NoVectorization,CompleteUnrolling));
  
  VERIFY(test_sum(Matrix<float,6,2>(),
    LinearVectorization,CompleteUnrolling));

  VERIFY(test_sum(Matrix<float,16,16>(),
    LinearVectorization,NoUnrolling));

  VERIFY(test_sum(Matrix<float,16,16>().block<4,4>(1,2),
    NoVectorization,CompleteUnrolling));

#ifndef EIGEN_DEFAULT_TO_ROW_MAJOR
  VERIFY(test_sum(Matrix<float,16,16>().block<8,1>(1,2),
    LinearVectorization,CompleteUnrolling));
#endif

  VERIFY(test_sum(Matrix<double,7,3>(),
    NoVectorization,CompleteUnrolling));

#endif // EIGEN_VECTORIZE

}
示例#14
0
文件: stmt.c 项目: tcadigan/gbII_6.0
/* FOR stuff */
void cmd_for(char *args)
{
    char loopname[SMABUF]; /* Loop name - string form */
    char holdbuf[NORMSIZ]; /* Command section of the for */
    char val[MAXSIZ]; /* Buffer to build up things for add_queue */
    int firstval = 0; /* Low val */
    int lastval = -1; /* High val */
    int crement; /* Decrement or increment */
    int nooutput = false; /* Show or not on msg stuff */
    int i; /* Counter */
    char *p;
    char *q;
    char *r;

    p = first(args);
    r = args; /* Keep this, splitting string here */

    if (!*p) {
        msg("-- Usage: for loopname min,max command");
        msg("          for loopname (n1,n2,n3,...,nn) command");

        return;
    }
    else {
        if (!strcmp(p, "-nooutput")) {
            nooutput = true;
            q = rest(r);
            r = q; /* For down below when we get rest */
            p = first(q);
            debug(4, "for: nooutput is true, first is %s, rest is %s", p, r);

            if (!*p) {
                msg("-- Usage: for loopname min,max command");
                msg("          for loopname (n1,n2,n3,...,nn) command");

                return;
            }
        }

        strcpy(loopname, p);

        if (test_assign(loopname)) {
            msg("-- for: Requires an undefined loopname. Try a new name.");

            return;
        }

        if (!valid_assign_name(loopname)) {
            msg("-- for: Invalid loopname(%s). Must be char, num or _ only", loopname);

            return;
        }

        q = rest(r);

        if (!q) {
            *args = '\0';
        } else {
            strcpy(args, q);
        }
    }

    parse_variables(args);

    /* foreach() stuff */
    if (*args == '(') {
        p = strchr(args, ')'); /* Get end loop */

        if (!p) {
            msg("-- Usage: forloopname (n1,n2,n3,...,nn) command");

            return;
        }

        *p++ = '\0';
        strcpy(holdbuf, p);
        q = args + 1;
        p = strchr(q, ',');

        while (p) {
            *p = '\0';
            sprintf(val, "assign ^%s %s", loopname, q);
            add_queue(val, 1);
            sprintf(val, "msg \'%s\'", holdbuf);
            add_queue(val, 0);
            add_queue(holdbuf, 0);
            q = p + 1;
            p = strchr(q, ',');
        }

        sprintf(val, "assign ^%s %s", loopname, q);
        add_queue(val, 1);
        sprintf(val, "msg \'%s\'", holdbuf);
        add_queue(val, 0);
        add_queue(holdbuf, 0);
        sprintf(val, "assign -^%s", loopname);
        add_queue(val, 0);

        if (!nooutput) {
            add_queue("echo -- for done.", 0);
        }

        return;
    }

    /* Old for loop stuff below */
    p = first(args);

    if (!p || !*p) {
        msg("-- Usage: for loopname min,max command");
        msg("          for loopname (n1,n2,n3,...,nn) command");

        return;
    }

    q = strchr(p, ',');

    if (!q
        || (!isdigit(*(q + 1)) && *(q + 1) != '-')
        || (*(q + 1) == '-' && !isdigit(*(q + 2)))) {
        msg("-- Usage: for loopname min,max command");

        return;
    }

    *q = '\0';
    q++;
    firstval = atoi(p);
    lastval = atoi(q);

    if (lastval < firstval) {
        crement = -1;
    } else {
        crement = 1;
    }

    q = rest(args);

    if (!q) {
        msg("-- Usage: for loopname min,max command");

        return;
    } else {
        strcpy(holdbuf, q);
    }

    i = firstval;
    lastval += crement;

    while (i != lastval) {
        /* By pass the msg system with the ^ */
        sprintf(val, "assign ^%s %d", loopname, i);
        add_queue(val, 1);
        sprintf(val, "msg \'%s\'", holdbuf);
        add_queue(val, 0);
        add_queue(holdbuf, 0);
        i += crement;
    }

    sprintf(val, "assign -^%s", loopname);
    add_queue(val, 0);

    if (!nooutput) {
        add_queue("echo -- for done.", 0);
    }
}