From bdf677825c422e47832d0282954769f390cd58fd Mon Sep 17 00:00:00 2001 From: Christoph Lehner Date: Fri, 12 Jul 2024 15:48:40 +0200 Subject: [PATCH] missing files --- .../ad/reverse/foundation/matrix/__init__.py | 19 ++++++++ lib/gpt/ad/reverse/foundation/matrix/exp.py | 43 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 lib/gpt/ad/reverse/foundation/matrix/__init__.py create mode 100644 lib/gpt/ad/reverse/foundation/matrix/exp.py diff --git a/lib/gpt/ad/reverse/foundation/matrix/__init__.py b/lib/gpt/ad/reverse/foundation/matrix/__init__.py new file mode 100644 index 00000000..1d6d9368 --- /dev/null +++ b/lib/gpt/ad/reverse/foundation/matrix/__init__.py @@ -0,0 +1,19 @@ +# +# GPT - Grid Python Toolkit +# Copyright (C) 2023 Christoph Lehner (christoph.lehner@ur.de, https://github.com/lehner/gpt) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +import gpt.ad.reverse.foundation.matrix.exp diff --git a/lib/gpt/ad/reverse/foundation/matrix/exp.py b/lib/gpt/ad/reverse/foundation/matrix/exp.py new file mode 100644 index 00000000..f75100cb --- /dev/null +++ b/lib/gpt/ad/reverse/foundation/matrix/exp.py @@ -0,0 +1,43 @@ +# +# GPT - Grid Python Toolkit +# Copyright (C) 2023 Christoph Lehner (christoph.lehner@ur.de, https://github.com/lehner/gpt) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +import gpt as g +import numpy as np + + +def function(x): + fac = 1.0 + base = 128.0 + nbase = 7 + x = x / base + c = x + r = g.identity(x) + for i in range(1, 10): + fac /= float(i) + r = r + fac * c + c = c * x + for i in range(nbase): + r = r * r + return r + + +# gives 1e-14 / 1e-15 errors up to at least |x| < 10 + + +def function_and_gradient(x, dx): + assert False