# Path: attitude/geom/util.py
# def dot(*matrices):
#     return reduce(N.dot, matrices)


import numpy as N
from ....geom import dot
"""
A temporary module for holding regression functions before merging
with the main regression functionality of the module
"""

def hyperbola(cov, axes, means, xvals, n=1,level=1):

    cov1 = dot(axes.T,cov,axes)
    # Plot hyperbola
    a = N.sqrt(cov[0]) #hyp_axes[0]
    b = N.sqrt(cov[-1]) #hyp_axes[-1]

    #a = N.sqrt(cov[0])#1[0]) #hyp_axes[0]
    #b = N.sqrt(cov[-1])#1[-1]) #hyp_axes[-1]
    u = lambda x: N.arcsinh(x/a)
    y = lambda x: b*N.cosh(u(x))

    def y(x):
        return level*b*N.sqrt(x**2/(a**2*n)+1/n)

    # Top
    vals = N.array([xvals,y(xvals)]).transpose()

# Path: attitude/geom/util.py
# def dot(*matrices):
#     return reduce(N.dot, matrices)


# Path: attitude/display/plot/cov_types/regressions.py
import numpy as N
from ....geom import dot

"""
A temporary module for holding regression functions before merging
with the main regression functionality of the module
"""

def hyperbola(cov, axes, means, xvals, n=1,level=1):

    cov1 = dot(axes.T,cov,axes)
    # Plot hyperbola
    a = N.sqrt(cov[0]) #hyp_axes[0]
    b = N.sqrt(cov[-1]) #hyp_axes[-1]

    #a = N.sqrt(cov[0])#1[0]) #hyp_axes[0]
    #b = N.sqrt(cov[-1])#1[-1]) #hyp_axes[-1]
    u = lambda x: N.arcsinh(x/a)
    y = lambda x: b*N.cosh(u(x))

    def y(x):
        return level*b*N.sqrt(x**2/(a**2*n)+1/n)

    # Top
    vals = N.array([xvals,y(xvals)]).transpose()

    t = dot(vals,axes).T+means[:,N.newaxis]