From 422700fd315ef96501f151a2055c762d44edf9b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=BCnther?= Date: Fri, 3 Jun 2022 10:05:39 +0200 Subject: [PATCH] add LinearModelling operator --- pygimli/frameworks/__init__.py | 2 +- pygimli/frameworks/modelling.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/pygimli/frameworks/__init__.py b/pygimli/frameworks/__init__.py index 63f07cd90..a7a5cbc74 100644 --- a/pygimli/frameworks/__init__.py +++ b/pygimli/frameworks/__init__.py @@ -3,7 +3,7 @@ from .modelling import (Modelling, Block1DModelling, MeshModelling, - JointModelling, PriorModelling, + JointModelling, PriorModelling, LinearModelling, PetroModelling, LCModelling, ParameterModelling) from .inversion import (Inversion, MarquardtInversion, diff --git a/pygimli/frameworks/modelling.py b/pygimli/frameworks/modelling.py index cd267212c..e3c49e4cf 100644 --- a/pygimli/frameworks/modelling.py +++ b/pygimli/frameworks/modelling.py @@ -412,6 +412,28 @@ def drawData(self, ax, data, **kwargs): raise Exception("No yet implemented") +class LinearModelling(Modelling): + """Modelling class for linearized problems with a given matrix.""" + def __init__(self, A): + """Initialize by storing the (reference to the) matrix.""" + super().__init__() + self.A = A + self.setJacobian(self.A) + + def response(self, model): + """Linearized forward modelling by matrix-vector product.""" + return self.A * model + + def createJacobian(self, model): + """Do not compute a jacobian (linear).""" + pass + + @property + def parameterCount(self): + """Define the number of parameters from the matrix size.""" + return self.A.cols() + + class Block1DModelling(Modelling): """General forward operator for 1D layered models.