# Path: jaxopt/tree_util.py



import functools
import jax
import jax.numpy as jnp
import numpy as onp
from jaxopt.tree_util import tree_map, tree_sum, tree_mul
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Interface for linear operators."""




class DenseLinearOperator:

  def __init__(self, pytree):
    self.pytree = pytree

  def __call__(self, x):
    return self.matvec(x)

  def matvec(self, x):

# Path: jaxopt/tree_util.py



# Path: jaxopt/_src/linear_operator.py
import functools
import jax
import jax.numpy as jnp
import numpy as onp
from jaxopt.tree_util import tree_map, tree_sum, tree_mul

# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Interface for linear operators."""




class DenseLinearOperator:

  def __init__(self, pytree):
    self.pytree = pytree

  def __call__(self, x):
    return self.matvec(x)

  def matvec(self, x):

    return tree_map(jnp.dot, self.pytree, x)