# Copyright 2014-2018 Intel Corporation.
#
# This software and the related documents are Intel copyrighted  materials,  and
# your use of  them is  governed by the  express license  under which  they were
# provided to you (License).  Unless the License provides otherwise, you may not
# use, modify, copy, publish, distribute,  disclose or transmit this software or
# the related documents without Intel's prior written permission.
#
# This software and the related documents  are provided as  is,  with no express
# or implied  warranties,  other  than those  that are  expressly stated  in the
# License.



from sys import version_info
if version_info >= (2, 6, 0):
    def swig_import_helper():
        from os.path import dirname
        import imp
        fp = None
        try:
            fp, pathname, description = imp.find_module('_lbfgs', [dirname(__file__)])
        except ImportError:
            import _lbfgs
            return _lbfgs
        if fp is not None:
            try:
                _mod = imp.load_module('_lbfgs', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _lbfgs = swig_import_helper()
    del swig_import_helper
else:
    import _lbfgs
del version_info
try:
    _swig_property = property
except NameError:
    pass  # Python < 2.2 doesn't have 'property'.


def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
    if (name == "thisown"):
        return self.this.own(value)
    if (name == "this"):
        if type(value).__name__ == 'SwigPyObject':
            self.__dict__[name] = value
            return
    method = class_type.__swig_setmethods__.get(name, None)
    if method:
        return method(self, value)
    if (not static):
        if _newclass:
            object.__setattr__(self, name, value)
        else:
            self.__dict__[name] = value
    else:
        raise AttributeError("You cannot add attributes to %s" % self)


def _swig_setattr(self, class_type, name, value):
    return _swig_setattr_nondynamic(self, class_type, name, value, 0)


def _swig_getattr_nondynamic(self, class_type, name, static=1):
    if (name == "thisown"):
        return self.this.own()
    method = class_type.__swig_getmethods__.get(name, None)
    if method:
        return method(self)
    if (not static):
        return object.__getattr__(self, name)
    else:
        raise AttributeError(name)

def _swig_getattr(self, class_type, name):
    return _swig_getattr_nondynamic(self, class_type, name, 0)


def _swig_repr(self):
    try:
        strthis = "proxy of " + self.this.__repr__()
    except:
        strthis = ""
    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)

try:
    _object = object
    _newclass = 1
except AttributeError:
    class _object:
        pass
    _newclass = 0


import daal.algorithms.optimization_solver.iterative_solver
import daal.algorithms.optimization_solver
import daal.algorithms
import daal.data_management
import daal
import daal.services
import daal.data_management.features
import daal.algorithms.optimization_solver.sum_of_functions
import daal.algorithms.optimization_solver.objective_function
import daal.algorithms.engines.mt19937
import daal.algorithms.engines

_lbfgs.defaultDense_swigconstant(_lbfgs)
defaultDense = _lbfgs.defaultDense

_lbfgs.correctionPairs_swigconstant(_lbfgs)
correctionPairs = _lbfgs.correctionPairs

_lbfgs.correctionIndices_swigconstant(_lbfgs)
correctionIndices = _lbfgs.correctionIndices

_lbfgs.averageArgumentLIterations_swigconstant(_lbfgs)
averageArgumentLIterations = _lbfgs.averageArgumentLIterations

_lbfgs.lastOptionalData_swigconstant(_lbfgs)
lastOptionalData = _lbfgs.lastOptionalData
class Parameter(daal.algorithms.optimization_solver.iterative_solver.Parameter):
    __swig_setmethods__ = {}
    for _s in [daal.algorithms.optimization_solver.iterative_solver.Parameter]:
        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
    __setattr__ = lambda self, name, value: _swig_setattr(self, Parameter, name, value)
    __swig_getmethods__ = {}
    for _s in [daal.algorithms.optimization_solver.iterative_solver.Parameter]:
        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
    __getattr__ = lambda self, name: _swig_getattr(self, Parameter, name)
    __repr__ = _swig_repr

    def __init__(self, *args):
        this = _lbfgs.new_Parameter(*args)
        try:
            self.this.append(this)
        except:
            self.this = this
    __swig_destroy__ = _lbfgs.delete_Parameter
    __del__ = lambda self: None
    __swig_setmethods__["m"] = _lbfgs.Parameter_m_set
    __swig_getmethods__["m"] = _lbfgs.Parameter_m_get
    if _newclass:
        m = _swig_property(_lbfgs.Parameter_m_get, _lbfgs.Parameter_m_set)
    __swig_setmethods__["L"] = _lbfgs.Parameter_L_set
    __swig_getmethods__["L"] = _lbfgs.Parameter_L_get
    if _newclass:
        L = _swig_property(_lbfgs.Parameter_L_get, _lbfgs.Parameter_L_set)
    __swig_setmethods__["seed"] = _lbfgs.Parameter_seed_set
    __swig_getmethods__["seed"] = _lbfgs.Parameter_seed_get
    if _newclass:
        seed = _swig_property(_lbfgs.Parameter_seed_get, _lbfgs.Parameter_seed_set)
    __swig_setmethods__["engine"] = _lbfgs.Parameter_engine_set
    __swig_getmethods__["engine"] = _lbfgs.Parameter_engine_get
    if _newclass:
        engine = _swig_property(_lbfgs.Parameter_engine_get, _lbfgs.Parameter_engine_set)
    __swig_setmethods__["batchIndices"] = _lbfgs.Parameter_batchIndices_set
    __swig_getmethods__["batchIndices"] = _lbfgs.Parameter_batchIndices_get
    if _newclass:
        batchIndices = _swig_property(_lbfgs.Parameter_batchIndices_get, _lbfgs.Parameter_batchIndices_set)
    __swig_setmethods__["correctionPairBatchSize"] = _lbfgs.Parameter_correctionPairBatchSize_set
    __swig_getmethods__["correctionPairBatchSize"] = _lbfgs.Parameter_correctionPairBatchSize_get
    if _newclass:
        correctionPairBatchSize = _swig_property(_lbfgs.Parameter_correctionPairBatchSize_get, _lbfgs.Parameter_correctionPairBatchSize_set)
    __swig_setmethods__["correctionPairBatchIndices"] = _lbfgs.Parameter_correctionPairBatchIndices_set
    __swig_getmethods__["correctionPairBatchIndices"] = _lbfgs.Parameter_correctionPairBatchIndices_get
    if _newclass:
        correctionPairBatchIndices = _swig_property(_lbfgs.Parameter_correctionPairBatchIndices_get, _lbfgs.Parameter_correctionPairBatchIndices_set)
    __swig_setmethods__["stepLengthSequence"] = _lbfgs.Parameter_stepLengthSequence_set
    __swig_getmethods__["stepLengthSequence"] = _lbfgs.Parameter_stepLengthSequence_get
    if _newclass:
        stepLengthSequence = _swig_property(_lbfgs.Parameter_stepLengthSequence_get, _lbfgs.Parameter_stepLengthSequence_set)

    def check(self):
        return _lbfgs.Parameter_check(self)
Parameter_swigregister = _lbfgs.Parameter_swigregister
Parameter_swigregister(Parameter)

class Input(daal.algorithms.optimization_solver.iterative_solver.Input):
    __swig_setmethods__ = {}
    for _s in [daal.algorithms.optimization_solver.iterative_solver.Input]:
        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
    __setattr__ = lambda self, name, value: _swig_setattr(self, Input, name, value)
    __swig_getmethods__ = {}
    for _s in [daal.algorithms.optimization_solver.iterative_solver.Input]:
        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
    __getattr__ = lambda self, name: _swig_getattr(self, Input, name)
    __repr__ = _swig_repr

    def __init__(self, *args):
        this = _lbfgs.new_Input(*args)
        try:
            self.this.append(this)
        except:
            self.this = this

    def set(self, id, ptr):
        return _lbfgs.Input_set(self, id, ptr)

    def get(self, id):
        return _lbfgs.Input_get(self, id)

    def getOptionalData(self, id):
        return _lbfgs.Input_getOptionalData(self, id)

    def setOptionalData(self, id, ptr):
        return _lbfgs.Input_setOptionalData(self, id, ptr)

    def check(self, par, method):
        return _lbfgs.Input_check(self, par, method)
    __swig_destroy__ = _lbfgs.delete_Input
    __del__ = lambda self: None
Input_swigregister = _lbfgs.Input_swigregister
Input_swigregister(Input)

class Result(daal.algorithms.optimization_solver.iterative_solver.Result):
    __swig_setmethods__ = {}
    for _s in [daal.algorithms.optimization_solver.iterative_solver.Result]:
        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
    __setattr__ = lambda self, name, value: _swig_setattr(self, Result, name, value)
    __swig_getmethods__ = {}
    for _s in [daal.algorithms.optimization_solver.iterative_solver.Result]:
        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
    __getattr__ = lambda self, name: _swig_getattr(self, Result, name)
    __repr__ = _swig_repr
    __swig_getmethods__["serializationTag"] = lambda x: _lbfgs.Result_serializationTag
    if _newclass:
        serializationTag = staticmethod(_lbfgs.Result_serializationTag)

    def getSerializationTag(self):
        return _lbfgs.Result_getSerializationTag(self)

    def __init__(self):
        this = _lbfgs.new_Result()
        try:
            self.this.append(this)
        except:
            self.this = this

    def set(self, id, ptr):
        return _lbfgs.Result_set(self, id, ptr)

    def get(self, id):
        return _lbfgs.Result_get(self, id)

    def getOptionalData(self, id):
        return _lbfgs.Result_getOptionalData(self, id)

    def setOptionalData(self, id, ptr):
        return _lbfgs.Result_setOptionalData(self, id, ptr)

    def check(self, input, par, method):
        return _lbfgs.Result_check(self, input, par, method)

    def allocate_Float64(self, input, par, method):
        r"""
    This function is specialized for float64"""
        return _lbfgs.Result_allocate_Float64(self, input, par, method)


    def allocate_Float32(self, input, par, method):
        r"""
    This function is specialized for float32"""
        return _lbfgs.Result_allocate_Float32(self, input, par, method)

    __swig_destroy__ = _lbfgs.delete_Result
    __del__ = lambda self: None
Result_swigregister = _lbfgs.Result_swigregister
Result_swigregister(Result)

def Result_serializationTag():
    return _lbfgs.Result_serializationTag()
Result_serializationTag = _lbfgs.Result_serializationTag

class Batch_Float64DefaultDense(daal.algorithms.optimization_solver.iterative_solver.Batch):
    r"""
    This class is an alias of Batch()
    """
    __swig_setmethods__ = {}
    for _s in [daal.algorithms.optimization_solver.iterative_solver.Batch]:
        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
    __setattr__ = lambda self, name, value: _swig_setattr(self, Batch_Float64DefaultDense, name, value)
    __swig_getmethods__ = {}
    for _s in [daal.algorithms.optimization_solver.iterative_solver.Batch]:
        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
    __getattr__ = lambda self, name: _swig_getattr(self, Batch_Float64DefaultDense, name)
    __repr__ = _swig_repr
    __swig_setmethods__["input"] = _lbfgs.Batch_Float64DefaultDense_input_set
    __swig_getmethods__["input"] = _lbfgs.Batch_Float64DefaultDense_input_get
    if _newclass:
        input = _swig_property(_lbfgs.Batch_Float64DefaultDense_input_get, _lbfgs.Batch_Float64DefaultDense_input_set)
    __swig_setmethods__["parameter"] = _lbfgs.Batch_Float64DefaultDense_parameter_set
    __swig_getmethods__["parameter"] = _lbfgs.Batch_Float64DefaultDense_parameter_get
    if _newclass:
        parameter = _swig_property(_lbfgs.Batch_Float64DefaultDense_parameter_get, _lbfgs.Batch_Float64DefaultDense_parameter_set)

    def __init__(self, *args):
        this = _lbfgs.new_Batch_Float64DefaultDense(*args)
        try:
            self.this.append(this)
        except:
            self.this = this

    def getMethod(self):
        return _lbfgs.Batch_Float64DefaultDense_getMethod(self)

    def getInput(self):
        return _lbfgs.Batch_Float64DefaultDense_getInput(self)

    def getParameter(self):
        return _lbfgs.Batch_Float64DefaultDense_getParameter(self)

    def createResult(self):
        return _lbfgs.Batch_Float64DefaultDense_createResult(self)

    def clone(self):
        return _lbfgs.Batch_Float64DefaultDense_clone(self)
    __swig_getmethods__["create"] = lambda x: _lbfgs.Batch_Float64DefaultDense_create
    if _newclass:
        create = staticmethod(_lbfgs.Batch_Float64DefaultDense_create)

    def compute(self):
        return _lbfgs.Batch_Float64DefaultDense_compute(self)
    __swig_destroy__ = _lbfgs.delete_Batch_Float64DefaultDense
    __del__ = lambda self: None
Batch_Float64DefaultDense_swigregister = _lbfgs.Batch_Float64DefaultDense_swigregister
Batch_Float64DefaultDense_swigregister(Batch_Float64DefaultDense)

def Batch_Float64DefaultDense_create():
    return _lbfgs.Batch_Float64DefaultDense_create()
Batch_Float64DefaultDense_create = _lbfgs.Batch_Float64DefaultDense_create

class Batch_Float32DefaultDense(daal.algorithms.optimization_solver.iterative_solver.Batch):
    r"""
    This class is an alias of Batch()
    """
    __swig_setmethods__ = {}
    for _s in [daal.algorithms.optimization_solver.iterative_solver.Batch]:
        __swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))
    __setattr__ = lambda self, name, value: _swig_setattr(self, Batch_Float32DefaultDense, name, value)
    __swig_getmethods__ = {}
    for _s in [daal.algorithms.optimization_solver.iterative_solver.Batch]:
        __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
    __getattr__ = lambda self, name: _swig_getattr(self, Batch_Float32DefaultDense, name)
    __repr__ = _swig_repr
    __swig_setmethods__["input"] = _lbfgs.Batch_Float32DefaultDense_input_set
    __swig_getmethods__["input"] = _lbfgs.Batch_Float32DefaultDense_input_get
    if _newclass:
        input = _swig_property(_lbfgs.Batch_Float32DefaultDense_input_get, _lbfgs.Batch_Float32DefaultDense_input_set)
    __swig_setmethods__["parameter"] = _lbfgs.Batch_Float32DefaultDense_parameter_set
    __swig_getmethods__["parameter"] = _lbfgs.Batch_Float32DefaultDense_parameter_get
    if _newclass:
        parameter = _swig_property(_lbfgs.Batch_Float32DefaultDense_parameter_get, _lbfgs.Batch_Float32DefaultDense_parameter_set)

    def __init__(self, *args):
        this = _lbfgs.new_Batch_Float32DefaultDense(*args)
        try:
            self.this.append(this)
        except:
            self.this = this

    def getMethod(self):
        return _lbfgs.Batch_Float32DefaultDense_getMethod(self)

    def getInput(self):
        return _lbfgs.Batch_Float32DefaultDense_getInput(self)

    def getParameter(self):
        return _lbfgs.Batch_Float32DefaultDense_getParameter(self)

    def createResult(self):
        return _lbfgs.Batch_Float32DefaultDense_createResult(self)

    def clone(self):
        return _lbfgs.Batch_Float32DefaultDense_clone(self)
    __swig_getmethods__["create"] = lambda x: _lbfgs.Batch_Float32DefaultDense_create
    if _newclass:
        create = staticmethod(_lbfgs.Batch_Float32DefaultDense_create)

    def compute(self):
        return _lbfgs.Batch_Float32DefaultDense_compute(self)
    __swig_destroy__ = _lbfgs.delete_Batch_Float32DefaultDense
    __del__ = lambda self: None
Batch_Float32DefaultDense_swigregister = _lbfgs.Batch_Float32DefaultDense_swigregister
Batch_Float32DefaultDense_swigregister(Batch_Float32DefaultDense)

def Batch_Float32DefaultDense_create():
    return _lbfgs.Batch_Float32DefaultDense_create()
Batch_Float32DefaultDense_create = _lbfgs.Batch_Float32DefaultDense_create

from numpy import float64, float32, intc

class Batch(object):
    r"""Factory class for different types of Batch."""
    def __new__(cls,
                *args, **kwargs):
        if 'fptype' not in kwargs or kwargs['fptype'] == float64:
            if 'method' not in kwargs or kwargs['method'] == defaultDense:
                return Batch_Float64DefaultDense(*args)
        if 'fptype' in kwargs and kwargs['fptype'] == float32:
            if 'method' not in kwargs or kwargs['method'] == defaultDense:
                return Batch_Float32DefaultDense(*args)

        raise RuntimeError("No appropriate constructor found for Batch")


# This file is compatible with both classic and new-style classes.


