# 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 _sparsemat
else:
    import _sparsemat

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__)


class SparseMat(object):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, nr, nc):
        _sparsemat.SparseMat_swiginit(self, _sparsemat.new_SparseMat(nr, nc))
    __swig_destroy__ = _sparsemat.delete_SparseMat

    def clone(self):
        return _sparsemat.SparseMat_clone(self)

    def nrows(self):
        return _sparsemat.SparseMat_nrows(self)

    def ncols(self):
        return _sparsemat.SparseMat_ncols(self)

    def nnonzeros(self):
        return _sparsemat.SparseMat_nnonzeros(self)

    def resize(self, nr, nc):
        return _sparsemat.SparseMat_resize(self, nr, nc)

    def reserve(self, size):
        return _sparsemat.SparseMat_reserve(self, size)

    def insert(self, ir, ic, val):
        return _sparsemat.SparseMat_insert(self, ir, ic, val)

    def empty(self):
        return _sparsemat.SparseMat_empty(self)

    def is_nonempty_row(self, arg2):
        return _sparsemat.SparseMat_is_nonempty_row(self, arg2)

    def is_nonempty_col(self, arg2):
        return _sparsemat.SparseMat_is_nonempty_col(self, arg2)

    def lower(self):
        return _sparsemat.SparseMat_lower(self)

    def unit_lower(self):
        return _sparsemat.SparseMat_unit_lower(self)

    def upper(self):
        return _sparsemat.SparseMat_upper(self)

    def unit_upper(self):
        return _sparsemat.SparseMat_unit_upper(self)

    def norm(self):
        return _sparsemat.SparseMat_norm(self)

    def transpose(self):
        return _sparsemat.SparseMat_transpose(self)

    def add(self, arg2, arg3):
        return _sparsemat.SparseMat_add(self, arg2, arg3)

    def trans_mult(self, arg2):
        return _sparsemat.SparseMat_trans_mult(self, arg2)

    def axpy(self, alpha, x, y):
        return _sparsemat.SparseMat_axpy(self, alpha, x, y)

    def axpy_trans(self, alpha, x, y):
        return _sparsemat.SparseMat_axpy_trans(self, alpha, x, y)

    def solve_lower_triangle(self, arg2, arg3):
        return _sparsemat.SparseMat_solve_lower_triangle(self, arg2, arg3)

    def solve_lower_triangle_unitd(self, arg2, arg3):
        return _sparsemat.SparseMat_solve_lower_triangle_unitd(self, arg2, arg3)

    def solve_lower_triangle_trans(self, arg2, arg3):
        return _sparsemat.SparseMat_solve_lower_triangle_trans(self, arg2, arg3)

    def solve_lower_triangle_trans_unitd(self, arg2, arg3):
        return _sparsemat.SparseMat_solve_lower_triangle_trans_unitd(self, arg2, arg3)

    def solve_upper_triangle(self, arg2, arg3):
        return _sparsemat.SparseMat_solve_upper_triangle(self, arg2, arg3)

    def solve_upper_triangle_trans(self, arg2, arg3):
        return _sparsemat.SparseMat_solve_upper_triangle_trans(self, arg2, arg3)

    def is_lower_triangular(self, diag):
        return _sparsemat.SparseMat_is_lower_triangular(self, diag)

    def is_upper_triangular(self, diag):
        return _sparsemat.SparseMat_is_upper_triangular(self, diag)

    def is_symmetric(self, tolerance):
        return _sparsemat.SparseMat_is_symmetric(self, tolerance)

    def str(self):
        return _sparsemat.SparseMat_str(self)

    def scale(self, a):
        return _sparsemat.SparseMat_scale(self, a)

    def matrixmultiply(self, m):
        return _sparsemat.SparseMat_matrixmultiply(self, m)

    def __repr__(self):
        return _sparsemat.SparseMat___repr__(self)

    def save(self, filename):
        return _sparsemat.SparseMat_save(self, filename)

    def load(self, filename):
        return _sparsemat.SparseMat_load(self, filename)

# Register SparseMat in _sparsemat:
_sparsemat.SparseMat_swigregister(SparseMat)
# -*- 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.SWIG.common import doublevec

def _sparsemat___size__(self):
    return (self.nrows(), self.ncols())
SparseMat.size = _sparsemat___size__

def _sparsemat___iadd__(self, other):
    if isinstance(other, SparseMat):
        self.add(1.0, other)
        return self
    return NotImplemented
SparseMat.__iadd__ = _sparsemat___iadd__

def _sparsemat___add__(self, other):
    result = self.clone()
    result += other
    return result
SparseMat.__add__ = _sparsemat___add__

def _sparsemat___isub__(self, other):
    if isinstance(other, SparseMat):
        self.add(-1.0, other)
        return self
    return NotImplemented
SparseMat.__isub__ = _sparsemat___isub__

def _sparsemat___sub__(self, other):
    result = self.clone()
    result -= other
    return result
SparseMat.__sub__ = _sparsemat___sub__

def _sparsemat___mul__(self, x):
    if isinstance(x, SparseMat):
        return self.matrixmultiply(x)
    if isinstance(x, doublevec.DoubleVec):
        result = doublevec.DoubleVec(self.nrows())
        self.axpy(1.0, x, result)
        return result
    result = self.clone()
    result *= x
    return result
SparseMat.__mul__ = _sparsemat___mul__

def _sparsemat___rmul__(self, x):
    if isinstance(x, doublevec.DoubleVec):
        result = doublevec.DoubleVec(self.nrows())
        self.axpy_trans(1.0, x, result)
        return result
    result = self.clone()
    result *= x
    return result
SparseMat.__rmul__ = _sparsemat___rmul__

def _sparsemat___imul__(self, x):
    if isinstance(x, float) or isinstance(x, int):
        self.scale(x)
        return self
    return NotImplemented
SparseMat.__imul__ = _sparsemat___imul__

def _sparsemat___itruediv__(self, x):
    if isinstance(x, float) or isinstance(x, int):
        self.scale(1./x)
        return self
    return NotImplemented
SparseMat.__itruediv__ = _sparsemat___itruediv__

def _sparsemat___truediv__(self, x):
        result = self.clone()
        result /= x
        return result
SparseMat.__truediv__ = _sparsemat___truediv__



