From b9dae35e0deecd509a51d03d47d341de7924ef16 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Thu, 8 Oct 2015 08:17:25 +0200 Subject: [PATCH] Observer norm complement and documentation --- doc/en/ref_observers_requirements.rst | 13 +++++++++++++ doc/fr/ref_observers_requirements.rst | 13 +++++++++++++ src/daComposant/daCore/Templates.py | 7 +++++++ 3 files changed, 33 insertions(+) diff --git a/doc/en/ref_observers_requirements.rst b/doc/en/ref_observers_requirements.rst index f0edbd2..376b9cd 100644 --- a/doc/en/ref_observers_requirements.rst +++ b/doc/en/ref_observers_requirements.rst @@ -381,6 +381,19 @@ Print on standard output the variance of the current value of the variable. import numpy print info, numpy.nanvar(var[-1]) +.. index:: single: ValueL2Norm (Observer) + +Template **ValueL2Norm** : +.......................... + +Print on standard output the L2 norm of the current value of the variable. + +:: + + import numpy + v = numpy.matrix( numpy.ravel( var[-1] ) ) + print info, float( numpy.linalg.norm(v) ) + .. index:: single: ValueRMS (Observer) Template **ValueRMS** : diff --git a/doc/fr/ref_observers_requirements.rst b/doc/fr/ref_observers_requirements.rst index 42b6a24..90ebf8a 100644 --- a/doc/fr/ref_observers_requirements.rst +++ b/doc/fr/ref_observers_requirements.rst @@ -384,6 +384,19 @@ Imprime sur la sortie standard la variance de la valeur courante de la variable. import numpy print info, numpy.nanvar(var[-1]) +.. index:: single: ValueL2Norm (Observer) + +Modèle **ValueL2Norm** : +........................ + +Imprime sur la sortie standard la norme L2 de la valeur courante de la variable. + +:: + + import numpy + v = numpy.matrix( numpy.ravel( var[-1] ) ) + print info, float( numpy.linalg.norm(v) ) + .. index:: single: ValueRMS (Observer) Modèle **ValueRMS** : diff --git a/src/daComposant/daCore/Templates.py b/src/daComposant/daCore/Templates.py index 8bf8294..054f34b 100644 --- a/src/daComposant/daCore/Templates.py +++ b/src/daComposant/daCore/Templates.py @@ -197,6 +197,13 @@ ObserverTemplates.store( en_EN = "Print on standard output the variance of the current value of the variable", order = "next", ) +ObserverTemplates.store( + name = "ValueL2Norm", + content = """import numpy\nv = numpy.matrix( numpy.ravel( var[-1] ) )\nprint info, float( numpy.linalg.norm(v) )""", + fr_FR = "Imprime sur la sortie standard la norme L2 de la valeur courante de la variable", + en_EN = "Print on standard output the L2 norm of the current value of the variable", + order = "next", + ) ObserverTemplates.store( name = "ValueRMS", content = """import numpy\nv = numpy.matrix( numpy.ravel( var[-1] ) )\nprint info, float( numpy.sqrt((1./v.size)*(v*v.T)) )""", -- 2.39.2