https://github.com/ITensor/ITensor
Raw File
Tip revision: 6280c1a7de2effbc23eb21feaa87812bde0ac91b authored by Miles Stoudenmire on 09 August 2017, 04:50:32 UTC
New exactApplyMPO algorithm with better scaling (m^3k^2+m^2k^3) and less ad hoc approach to compression of resulting MPS
Tip revision: 6280c1a
algorithm_test.cc
#include "test.h"
#include "itensor/detail/algs.h"

using namespace itensor;
using namespace std;

TEST_CASE("binaryFind test")
    {

    std::vector<int> ints = {{ 1,3,6,7,9,10,12,14 }};

    SECTION("const container")
        {
        const auto& cints = ints;
        auto res = detail::binaryFind(cints,3);
        CHECK(res);
        auto assignable = std::is_assignable<decltype(*res),int>::value;
        CHECK(!assignable);
        }

    SECTION("non-const container")
        {
        auto res = detail::binaryFind(ints,3);
        CHECK(res);
        auto assignable = std::is_assignable<decltype(*res),int>::value;
        CHECK(assignable);
        }

    SECTION("Basic Functionality")
        {
        for(int i = 0; i <= 30; ++i)
            {
            auto res = detail::binaryFind(ints,i);
            //Do linear search for i to check
            bool found = false;
            for(const auto& el : ints)
                if(el == i)
                    {
                    found = true;
                    break;
                    }
            if(found) 
                {
                CHECK(res);
                CHECK(i == *res);
                }
            else CHECK(!res);
            }
        }
    }
back to top