# Path: blaspy/config.py
# BLAS_NAME = ""  # default is ""
# IN_BLASPY_SUBDIRECTORY = True  # default is True
#     PREPEND = str(path.dirname(__file__))[:-6] + "lib/"
#             BLAS_NAME = "libopenblas-0.2.13-win64-int32.dll"
#             BLAS_NAME = "libopenblas-0.2.13-win32.dll"
#         PREPEND = ""
#             BLAS_NAME = "libopenblas-0.2.13-linux64.so"
#             BLAS_NAME = "libopenblas-0.2.13-linux32.so"
#    PREPEND = ""
# 
# Path: blaspy/helpers.py
# def get_vector_dimensions(name, vector, stride):
#     """
#     Return the number of rows, number of columns, and length of a vector taking into account
#     the stride of the vector.
# 
#     Args:
#         name:      string to print as the vector's name if an error occurs
#         vector:    numpy 2D ndarray or matrix representing a vector
#         stride:    stride of the vector (increment for the elements of the vector)
# 
#     Returns:
#         A tuple of three elements where each element is described in order below:
# 
#         - number of rows in vector
#         - number of columns in vector
#         - length of vector after accounting for stride
# 
#     Raises:
#         TypeError: if vector is not a vector represented by a 2D NumPy ndarray or matrix
#     """
# 
#     try:
#         rows, cols = vector.shape
# 
#         if not (rows == 1 or cols == 1):
#             raise_not_vector(name, rows, cols)
# 
#         length = max(rows, cols)
#         if stride > 1:
#             length = (length / stride) + (length % stride > 0)
# 
#         return rows, cols, length
# 
#     except (AttributeError, TypeError):
#         raise_not_2d_numpy(name)
# 
# def check_equal_sizes(name_1, size_1, name_2, size_2):
#     """
#     Check that size_1 and size_2 are equal.
# 
#     Args:
#         name_1:    string to print as the name of the first element
#         size_1:    size of the first element
#         name_2:    string to print as the name of the second element
#         size_2:    size of the second element
# 
#     Raises:
#         ValueError: if size_1 != size_2
#     """
# 
#     if size_1 != size_2:
#         raise_size_mismatch(name_1, size_1, name_2, size_2)
# 
# Path: blaspy/errors.py
# def raise_invalid_dtypes(allowed):
#     raise ValueError("All matrix and vector parameters should have the same dtype and that dtype "
#                      "should be in the following list of allowed dtypes (which may change from "
#                      "one BLASpy function to another): %s. This error can be fixed calling "
#                      ".astype('dtype') on the problem ndarray or matrix before calling a BLASpy "
#                      "function with that ndarray or matrix as a parameter." % (allowed,))
# 
# def raise_invalid_parameter(name, allowed, actual):
#     raise ValueError("Parameter '%s' should equal one of the following values: %s. Actual value: "
#                      "%s" % (name, (allowed,), actual))


from ..config import _libblas
from ..helpers import get_vector_dimensions, check_equal_sizes
from ..errors import raise_invalid_dtypes, raise_invalid_parameter
from ctypes import c_int, c_double, c_float, POINTER
                        - x or y is not a vector
                        - x and y do not have the same length
                        - output is not equal to one of the following:'float64', 'float32'
    """

    # get the dimensions of the parameters
    m_x, n_x, x_length = get_vector_dimensions('x', x, inc_x)
    m_y, n_y, y_length = get_vector_dimensions('y', y, inc_y)

    # ensure the parameters are appropriate for the operation
    check_equal_sizes('x', x_length, 'y', y_length)

    # get_cblas_info cannot be used for sdot due to the way input/output data types don't
    # necessarily match. For now, this is handled in this function, but it may be moved into
    # helpers.py if it occurs again when implementing other CBLAS subroutines.

    # check type of x and y
    if not (x.dtype == 'float32' and y.dtype == 'float32'):
        raise_invalid_dtypes('float32')

    # determine which CBLAS routine to call based on data type, then call CBLAS using ctypes
    if output == 'float64':
        cblas_func = _libblas.cblas_dsdot
        ctype_x = POINTER(c_float * n_x * m_x)
        ctype_y = POINTER(c_float * n_y * m_y)
        cblas_func.argtypes = [c_int, ctype_x, c_int, ctype_y, c_int]
        cblas_func.restype = c_double
        return cblas_func(x_length, x.ctypes.data_as(ctype_x), inc_x,
                          y.ctypes.data_as(ctype_y), inc_y)
    elif output == 'float32':

# Path: blaspy/config.py
# BLAS_NAME = ""  # default is ""
# IN_BLASPY_SUBDIRECTORY = True  # default is True
#     PREPEND = str(path.dirname(__file__))[:-6] + "lib/"
#             BLAS_NAME = "libopenblas-0.2.13-win64-int32.dll"
#             BLAS_NAME = "libopenblas-0.2.13-win32.dll"
#         PREPEND = ""
#             BLAS_NAME = "libopenblas-0.2.13-linux64.so"
#             BLAS_NAME = "libopenblas-0.2.13-linux32.so"
#    PREPEND = ""
# 
# Path: blaspy/helpers.py
# def get_vector_dimensions(name, vector, stride):
#     """
#     Return the number of rows, number of columns, and length of a vector taking into account
#     the stride of the vector.
# 
#     Args:
#         name:      string to print as the vector's name if an error occurs
#         vector:    numpy 2D ndarray or matrix representing a vector
#         stride:    stride of the vector (increment for the elements of the vector)
# 
#     Returns:
#         A tuple of three elements where each element is described in order below:
# 
#         - number of rows in vector
#         - number of columns in vector
#         - length of vector after accounting for stride
# 
#     Raises:
#         TypeError: if vector is not a vector represented by a 2D NumPy ndarray or matrix
#     """
# 
#     try:
#         rows, cols = vector.shape
# 
#         if not (rows == 1 or cols == 1):
#             raise_not_vector(name, rows, cols)
# 
#         length = max(rows, cols)
#         if stride > 1:
#             length = (length / stride) + (length % stride > 0)
# 
#         return rows, cols, length
# 
#     except (AttributeError, TypeError):
#         raise_not_2d_numpy(name)
# 
# def check_equal_sizes(name_1, size_1, name_2, size_2):
#     """
#     Check that size_1 and size_2 are equal.
# 
#     Args:
#         name_1:    string to print as the name of the first element
#         size_1:    size of the first element
#         name_2:    string to print as the name of the second element
#         size_2:    size of the second element
# 
#     Raises:
#         ValueError: if size_1 != size_2
#     """
# 
#     if size_1 != size_2:
#         raise_size_mismatch(name_1, size_1, name_2, size_2)
# 
# Path: blaspy/errors.py
# def raise_invalid_dtypes(allowed):
#     raise ValueError("All matrix and vector parameters should have the same dtype and that dtype "
#                      "should be in the following list of allowed dtypes (which may change from "
#                      "one BLASpy function to another): %s. This error can be fixed calling "
#                      ".astype('dtype') on the problem ndarray or matrix before calling a BLASpy "
#                      "function with that ndarray or matrix as a parameter." % (allowed,))
# 
# def raise_invalid_parameter(name, allowed, actual):
#     raise ValueError("Parameter '%s' should equal one of the following values: %s. Actual value: "
#                      "%s" % (name, (allowed,), actual))


# Path: blaspy/level_1/sdot.py
from ..config import _libblas
from ..helpers import get_vector_dimensions, check_equal_sizes
from ..errors import raise_invalid_dtypes, raise_invalid_parameter
from ctypes import c_int, c_double, c_float, POINTER

                        - x or y is not a vector
                        - x and y do not have the same length
                        - output is not equal to one of the following:'float64', 'float32'
    """

    # get the dimensions of the parameters
    m_x, n_x, x_length = get_vector_dimensions('x', x, inc_x)
    m_y, n_y, y_length = get_vector_dimensions('y', y, inc_y)

    # ensure the parameters are appropriate for the operation
    check_equal_sizes('x', x_length, 'y', y_length)

    # get_cblas_info cannot be used for sdot due to the way input/output data types don't
    # necessarily match. For now, this is handled in this function, but it may be moved into
    # helpers.py if it occurs again when implementing other CBLAS subroutines.

    # check type of x and y
    if not (x.dtype == 'float32' and y.dtype == 'float32'):
        raise_invalid_dtypes('float32')

    # determine which CBLAS routine to call based on data type, then call CBLAS using ctypes
    if output == 'float64':
        cblas_func = _libblas.cblas_dsdot
        ctype_x = POINTER(c_float * n_x * m_x)
        ctype_y = POINTER(c_float * n_y * m_y)
        cblas_func.argtypes = [c_int, ctype_x, c_int, ctype_y, c_int]
        cblas_func.restype = c_double
        return cblas_func(x_length, x.ctypes.data_as(ctype_x), inc_x,
                          y.ctypes.data_as(ctype_y), inc_y)
    elif output == 'float32':

        cblas_func = _libblas.cblas_sdsdot