from __future__ import division
from hypothesis import given, assume
from math import sqrt, floor

from .common import *
from .. import dotv
from ..blis import NO_CONJUGATE, CONJUGATE


@given(
    ndarrays(min_len=10, max_len=100,
             min_val=-100.0, max_val=100.0, dtype='float64'),
    ndarrays(min_len=10, max_len=100,
             min_val=-100.0, max_val=100.0, dtype='float64'),
)
def test_memoryview_double_noconj(A, B):
    if len(A) < len(B):
        B = B[:len(A)]
    else:
        A = A[:len(B)]
    assume(A is not None)
    assume(B is not None)
    result = dotv(0, 0,
        A.shape[0],
        A, B,
        1, 1,)
    numpy_result = A.dot(B)
    assert_allclose([numpy_result], result, atol=1e-4, rtol=1e-4)


@given(
    ndarrays(min_len=10, max_len=100,
             min_val=-100.0, max_val=100.0, dtype='float32'),
    ndarrays(min_len=10, max_len=100,
             min_val=-100.0, max_val=100.0, dtype='float32'),
)
def test_memoryview_double_noconj(A, B):
    if len(A) < len(B):
        B = B[:len(A)]
    else:
        A = A[:len(B)]
    assume(A is not None)
    assume(B is not None)
    result = dotv(0, 0,
        A.shape[0],
        A, B,
        1, 1,)
    numpy_result = A.dot(B)
    assert_allclose([numpy_result], result, atol=1e-4, rtol=1e-4)
