# This file was automatically generated by SWIG (https://www.swig.org).
# Version 4.1.1
#
# Do not make changes to this file unless you know what you are doing - modify
# the SWIG interface file instead.

from sys import version_info as _swig_python_version_info
# Import the low-level C/C++ module
if __package__ or "." in __name__:
    from . import _outputval
else:
    import _outputval

try:
    import builtins as __builtin__
except ImportError:
    import __builtin__

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


def _swig_setattr_nondynamic_instance_variable(set):
    def set_instance_attr(self, name, value):
        if name == "this":
            set(self, name, value)
        elif name == "thisown":
            self.this.own(value)
        elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
            set(self, name, value)
        else:
            raise AttributeError("You cannot add instance attributes to %s" % self)
    return set_instance_attr


def _swig_setattr_nondynamic_class_variable(set):
    def set_class_attr(cls, name, value):
        if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
            set(cls, name, value)
        else:
            raise AttributeError("You cannot add class attributes to %s" % cls)
    return set_class_attr


def _swig_add_metaclass(metaclass):
    """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
    def wrapper(cls):
        return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
    return wrapper


class _SwigNonDynamicMeta(type):
    """Meta class to enforce nondynamic attributes (no new attributes) for a class"""
    __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)


import ooflib.SWIG.engine.fieldindex
import ooflib.SWIG.engine.planarity
class OutputVal(object):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr
    __swig_destroy__ = _outputval.delete_OutputVal

    def dim(self):
        return _outputval.OutputVal_dim(self)

    def getIndex(self, arg2):
        return _outputval.OutputVal_getIndex(self, arg2)

    def clone(self):
        return _outputval.OutputVal_clone(self)

    def zero(self):
        return _outputval.OutputVal_zero(self)

    def value_list(self):
        return _outputval.OutputVal_value_list(self)

    def c_components(self):
        return _outputval.OutputVal_c_components(self)

# Register OutputVal in _outputval:
_outputval.OutputVal_swigregister(OutputVal)
class NonArithmeticOutputVal(OutputVal):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr
    __swig_destroy__ = _outputval.delete_NonArithmeticOutputVal

# Register NonArithmeticOutputVal in _outputval:
_outputval.NonArithmeticOutputVal_swigregister(NonArithmeticOutputVal)
class ArithmeticOutputVal(OutputVal):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr

    def one(self):
        return _outputval.ArithmeticOutputVal_one(self)

    def component_pow(self, arg2):
        return _outputval.ArithmeticOutputVal_component_pow(self, arg2)

    def component_square(self):
        return _outputval.ArithmeticOutputVal_component_square(self)

    def component_sqrt(self):
        return _outputval.ArithmeticOutputVal_component_sqrt(self)

    def __getitem__(self, i):
        return _outputval.ArithmeticOutputVal___getitem__(self, i)
    __swig_destroy__ = _outputval.delete_ArithmeticOutputVal

# Register ArithmeticOutputVal in _outputval:
_outputval.ArithmeticOutputVal_swigregister(ArithmeticOutputVal)
class ScalarOutputVal(ArithmeticOutputVal):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, arg2):
        _outputval.ScalarOutputVal_swiginit(self, _outputval.new_ScalarOutputVal(arg2))

    def value(self):
        return _outputval.ScalarOutputVal_value(self)

    def __lt__(self, arg2):
        return _outputval.ScalarOutputVal___lt__(self, arg2)

    def _add(self, other):
        return _outputval.ScalarOutputVal__add(self, other)

    def _sub(self, other):
        return _outputval.ScalarOutputVal__sub(self, other)

    def _mul(self, other):
        return _outputval.ScalarOutputVal__mul(self, other)

    def __float__(self):
        return _outputval.ScalarOutputVal___float__(self)

    def __repr__(self):
        return _outputval.ScalarOutputVal___repr__(self)
    __swig_destroy__ = _outputval.delete_ScalarOutputVal

# Register ScalarOutputVal in _outputval:
_outputval.ScalarOutputVal_swigregister(ScalarOutputVal)
class VectorOutputVal(ArithmeticOutputVal):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def size(self):
        return _outputval.VectorOutputVal_size(self)

    def __init__(self, arg2):
        _outputval.VectorOutputVal_swiginit(self, _outputval.new_VectorOutputVal(arg2))

    def __repr__(self):
        return _outputval.VectorOutputVal___repr__(self)

    def _add(self, other):
        return _outputval.VectorOutputVal__add(self, other)

    def _sub(self, other):
        return _outputval.VectorOutputVal__sub(self, other)

    def _mul(self, other):
        return _outputval.VectorOutputVal__mul(self, other)

    def __getitem__(self, i):
        return _outputval.VectorOutputVal___getitem__(self, i)

    def __setitem__(self, i, x):
        return _outputval.VectorOutputVal___setitem__(self, i, x)
    __swig_destroy__ = _outputval.delete_VectorOutputVal

# Register VectorOutputVal in _outputval:
_outputval.VectorOutputVal_swigregister(VectorOutputVal)
class ListOutputVal(NonArithmeticOutputVal):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, arg2):
        _outputval.ListOutputVal_swiginit(self, _outputval.new_ListOutputVal(arg2))

    def size(self):
        return _outputval.ListOutputVal_size(self)

    def __repr__(self):
        return _outputval.ListOutputVal___repr__(self)

    def __getitem__(self, i):
        return _outputval.ListOutputVal___getitem__(self, i)

    def __setitem__(self, i, x):
        return _outputval.ListOutputVal___setitem__(self, i, x)
    __swig_destroy__ = _outputval.delete_ListOutputVal

# Register ListOutputVal in _outputval:
_outputval.ListOutputVal_swigregister(ListOutputVal)
class ListOutputValIndex(ooflib.SWIG.engine.fieldindex.FieldIndex):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr
    __swig_destroy__ = _outputval.delete_ListOutputValIndex

# Register ListOutputValIndex in _outputval:
_outputval.ListOutputValIndex_swigregister(ListOutputValIndex)
class OutputValue(object):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr
    __swig_destroy__ = _outputval.delete_OutputValue

    def valuePtr(self):
        return _outputval.OutputValue_valuePtr(self)

    def __init__(self, arg2):
        _outputval.OutputValue_swiginit(self, _outputval.new_OutputValue(arg2))

    def dim(self):
        return _outputval.OutputValue_dim(self)

    def valueClone(self):
        return _outputval.OutputValue_valueClone(self)

# Register OutputValue in _outputval:
_outputval.OutputValue_swigregister(OutputValue)
class NonArithmeticOutputValue(OutputValue):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr
    __swig_destroy__ = _outputval.delete_NonArithmeticOutputValue

# Register NonArithmeticOutputValue in _outputval:
_outputval.NonArithmeticOutputValue_swigregister(NonArithmeticOutputValue)
class ArithmeticOutputValue(OutputValue):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr

    def __getitem__(self, i):
        return _outputval.ArithmeticOutputValue___getitem__(self, i)

    def _add(self, other):
        return _outputval.ArithmeticOutputValue__add(self, other)

    def _mul(self, other):
        return _outputval.ArithmeticOutputValue__mul(self, other)
    __swig_destroy__ = _outputval.delete_ArithmeticOutputValue

# Register ArithmeticOutputValue in _outputval:
_outputval.ArithmeticOutputValue_swigregister(ArithmeticOutputValue)
# -*- python -*-

# This software was produced by NIST, an agency of the U.S. government,
# and by statute is not subject to copyright in the United States.
# Recipients of this software assume all responsibilities associated
# with its operation, modification and maintenance. However, to
# facilitate maintenance we ask that before distributing modified
# versions of this software, you first contact the authors at
# oof_manager@nist.gov. 


from ooflib.common import debug

_labels = ["X-component", "Y-component", "Z-component"]

# Header and representation data for OutputVal classes ---
# used by analysis machinery to format the output.

# Return appropriate subset of "X", "Y", "Z" if size is less than
# three, otherwise return numeric component indices starting from 1.
def _VectorOutputVal_label_list(self):
    s = self.size()
    if s <= len(_labels):
        return _labels[:s]
    else:
        return [repr(x)+'-component' for x in range(1,s+1)]

VectorOutputVal.label_list = _VectorOutputVal_label_list

def _ScalarOutputVal_label_list(self):
    return ["Value"]

ScalarOutputVal.label_list = _ScalarOutputVal_label_list


#################################################################

# Arithmetic operations for the OutputVal subclasses.  These must
# create a new object which Python has ownership of, otherwise data
# can get lost.  

def _VectorOutputVal___add__(self, other):
    res = self.clone()
    res._add(other)
    return res

VectorOutputVal.__add__ = _VectorOutputVal___add__
VectorOutputVal.__radd__ = _VectorOutputVal___add__


def _VectorOutputVal___sub__(self, other):
    res = self.clone()
    res._sub(other)
    return res

VectorOutputVal.__sub__ = _VectorOutputVal___sub__

def _ScalarOutputVal___add__(self, other):
    res = ScalarOutputVal(self.value())
    res._add(other)
    return res

ScalarOutputVal.__add__ = _ScalarOutputVal___add__
ScalarOutputVal.__radd__ = _ScalarOutputVal___add__


def _ScalarOutputVal___sub__(self, other):
    res = ScalarOutputVal(self.value())
    res._sub(other)
    return res

ScalarOutputVal.__sub__ = _ScalarOutputVal___sub__

def _OutputVal___pow__(self, power):
    bozo = self.clone()
    bozo.component_pow(power)
    return bozo

OutputVal.__pow__ = _OutputVal___pow__


# Multiplication and division only defined for scalar operands, of course.

def _VectorOutputVal___mul__(self, other):
    res = self.clone()
    res._mul(other)
    return res

VectorOutputVal.__mul__ = _VectorOutputVal___mul__
VectorOutputVal.__rmul__ = _VectorOutputVal___mul__


def _VectorOutputVal___truediv__(self, other):
    res = self.clone()
    res._mul(1.0/other)
    return res

VectorOutputVal.__truediv__ = _VectorOutputVal___truediv__


def _ScalarOutputVal___mul__(self, other):
    res = ScalarOutputVal(self.value())
    res._mul(other)
    return res

ScalarOutputVal.__mul__ = _ScalarOutputVal___mul__
ScalarOutputVal.__rmul__ = _ScalarOutputVal___mul__


def _ScalarOutputVal___truediv__(self, other):
    res = ScalarOutputVal(self.value())
    res._mul(1.0/other)
    return res

ScalarOutputVal.__truediv__ = _ScalarOutputVal___truediv__

# We need rdiv as well as div in order to compute 1/ScalarOutputVal.
def _ScalarOutputVal__rtruediv__(self, other):
    return other * (1.0/self.value())

ScalarOutputVal.__rtruediv__ = _ScalarOutputVal__rtruediv__

##############################

# Range is only meaningful for scalars.

def _ScalarOutputVal_expandRange(self, vmin, vmax):
    v = self.value()
    if vmin is not None:
        vmin = min(vmin, v)
    else:
        vmin = v
    if vmax is not None:
        vmax = max(vmax, v)
    else:
        vmax = v
    return (vmin, vmax)

ScalarOutputVal.expandRange = _ScalarOutputVal_expandRange

##############################

def _OutputValue___repr__(self):
    return repr(self.valuePtr())

OutputValue.__repr__ = _OutputValue___repr__


def _OutputValue__add__(self):
    res = OutputValue(self)
    res._add(other)
    return res

OutputValue.__add__ = _OutputValue__add__

def _OutputValue__mul__(self,other):
    res = OutputValue(self)
    res._mul(other)
    return res

OutputValue.__mul__ = _OutputValue__mul__

##############################

from ooflib.common.IO import parameter

## OutputValParameter is (probably) just used when specifying inputs
## for Outputs.

class OutputValParameter(parameter.Parameter):
    types=(OutputVal,)

##############################

def _OutputVal_components(self):
    comps = self.c_components()
    beginp = comps.begin()
    endp = comps.end()
    while beginp != endp:
        yield beginp.current()
        beginp.increment()

OutputVal.components = _OutputVal_components


