From e1f639640306dd62aeb199b8ab70b083258d16e5 Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Fri, 5 May 2023 10:04:52 +0000 Subject: automatic import of python-hyperjet --- python-hyperjet.spec | 359 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 359 insertions(+) create mode 100644 python-hyperjet.spec (limited to 'python-hyperjet.spec') diff --git a/python-hyperjet.spec b/python-hyperjet.spec new file mode 100644 index 0000000..4233157 --- /dev/null +++ b/python-hyperjet.spec @@ -0,0 +1,359 @@ +%global _empty_manifest_terminate_build 0 +Name: python-hyperjet +Version: 1.4.3 +Release: 1 +Summary: Automatic differentiation with dual numbers +License: MIT License +URL: https://github.com/oberbichler/HyperJet +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/22/d7/e13be7083835633362eeac427215e416d7268c5178206488cdec1090d813/hyperjet-1.4.3.tar.gz + +Requires: python3-numpy +Requires: python3-msvc-runtime +Requires: python3-pytest + +%description +A header-only library for algorithmic differentiation with hyper-dual numbers. Written in C++17 with an extensive Python interface. +[![PyPI](https://img.shields.io/pypi/v/hyperjet)](https://pypi.org/project/hyperjet) [![DOI](https://zenodo.org/badge/165487832.svg)](https://zenodo.org/badge/latestdoi/165487832) [![Build Status](https://github.com/oberbichler/HyperJet/workflows/Python%20package/badge.svg?branch=master)](https://github.com/oberbichler/HyperJet/actions) ![PyPI - License](https://img.shields.io/pypi/l/hyperjet) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hyperjet) ![PyPI - Format](https://img.shields.io/pypi/format/hyperjet) +## Installation +``` +pip install hyperjet +``` +## Quickstart +Import the module: +```python +import hyperjet as hj +``` +Create a set of variables e.g. `x=3` and `y=6`: +```python +x, y = hj.variables([3, 6]) +``` +`x` and `y` are hyper-dual numbers. This is indicated by the postfix `hj`: +```python +x +>>> 3hj +``` +Get the value as a simple `float`: +```python +x.f +>>> 3 +``` +The hyper-dual number stores the derivatives as a numpy array. +Get the first order derivatives (Gradient) of a hyper-dual number: +```python +x.g # = [dx/dx, dx/dy] +>>> array([1., 0.]) +``` +Get the second order derivatives (Hessian matrix): +```python +x.hm() # = [[d^2 x/ dx**2 , d^2 x/(dx*dy)], + # [d^2 x/(dx*dy), d^2 x/ dy**2 ]] +>>> array([[0., 0.], + [0., 0.]]) +``` +For a simple variable these derivatives are trivial. +Now do some computations: +```python +f = (x * y) / (x - y) +f +>>> -6hj +``` +The result is again a hyper-dual number. +Get the first order derivatives of `f` with respect to `x` and `y`: +```python +f.g # = [df/dx, df/dy] +>>> array([-4., 1.]) +``` +Get the second order derivatives of `f`: +```python +f.hm() # = [[d^2 f/ dx**2 , d^2 f/(dx*dy)], + # [d^2 f/(dx*dy), d^2 f/ dy**2 ]] +>>> array([[-2.66666667, 1.33333333], + [ 1.33333333, -0.66666667]]) +``` +You can use numpy to perform vector and matrix operations. +Compute the nomalized cross product of two vectors `u = [1, 2, 2]` and `v = [4, 1, -1]` with hyper-dual numbers: +```python +import numpy as np +variables = hj.DDScalar.variables([1, 2, 2, + 4, 1, -1]) +u = np.array(variables[:3]) # = [1hj, 2hj, 2hj] +v = np.array(variables[3:]) # = [4hj, 1hj, -1hj] +normal = np.cross(u, v) +normal /= np.linalg.norm(normal) +normal +>>> array([-0.331042hj, 0.744845hj, -0.579324hj], dtype=object) +``` +The result is a three-dimensional numpy array containing hyper-dual numbers. +Get the value and derivatives of the x-component: +```python +normal[0].f +>>> -0.3310423554409472 +normal[0].g +>>> array([ 0.00453483, -0.01020336, 0.00793595, 0.07255723, -0.16325376, 0.12697515]) +normal[0].hm() +>>> array([[ 0.00434846, -0.01091775, 0.00647611, -0.0029818 , -0.01143025, -0.02335746], + [-0.01091775, 0.02711578, -0.01655522, 0.00444165, 0.03081974, 0.04858632], + [ 0.00647611, -0.01655522, 0.0093492 , -0.00295074, -0.02510461, -0.03690759], + [-0.0029818 , 0.00444165, -0.00295074, -0.02956956, 0.03025289, -0.01546811], + [-0.01143025, 0.03081974, -0.02510461, 0.03025289, 0.01355789, -0.02868433], + [-0.02335746, 0.04858632, -0.03690759, -0.01546811, -0.02868433, 0.03641839]]) +``` +## Reference +If you use HyperJet, please refer to the official GitHub repository: +```bibtex +@misc{HyperJet, + author = "Thomas Oberbichler", + title = "HyperJet", + howpublished = "\url{http://github.com/oberbichler/HyperJet}", +} +``` + +%package -n python3-hyperjet +Summary: Automatic differentiation with dual numbers +Provides: python-hyperjet +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +BuildRequires: python3-cffi +BuildRequires: gcc +BuildRequires: gdb +%description -n python3-hyperjet +A header-only library for algorithmic differentiation with hyper-dual numbers. Written in C++17 with an extensive Python interface. +[![PyPI](https://img.shields.io/pypi/v/hyperjet)](https://pypi.org/project/hyperjet) [![DOI](https://zenodo.org/badge/165487832.svg)](https://zenodo.org/badge/latestdoi/165487832) [![Build Status](https://github.com/oberbichler/HyperJet/workflows/Python%20package/badge.svg?branch=master)](https://github.com/oberbichler/HyperJet/actions) ![PyPI - License](https://img.shields.io/pypi/l/hyperjet) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hyperjet) ![PyPI - Format](https://img.shields.io/pypi/format/hyperjet) +## Installation +``` +pip install hyperjet +``` +## Quickstart +Import the module: +```python +import hyperjet as hj +``` +Create a set of variables e.g. `x=3` and `y=6`: +```python +x, y = hj.variables([3, 6]) +``` +`x` and `y` are hyper-dual numbers. This is indicated by the postfix `hj`: +```python +x +>>> 3hj +``` +Get the value as a simple `float`: +```python +x.f +>>> 3 +``` +The hyper-dual number stores the derivatives as a numpy array. +Get the first order derivatives (Gradient) of a hyper-dual number: +```python +x.g # = [dx/dx, dx/dy] +>>> array([1., 0.]) +``` +Get the second order derivatives (Hessian matrix): +```python +x.hm() # = [[d^2 x/ dx**2 , d^2 x/(dx*dy)], + # [d^2 x/(dx*dy), d^2 x/ dy**2 ]] +>>> array([[0., 0.], + [0., 0.]]) +``` +For a simple variable these derivatives are trivial. +Now do some computations: +```python +f = (x * y) / (x - y) +f +>>> -6hj +``` +The result is again a hyper-dual number. +Get the first order derivatives of `f` with respect to `x` and `y`: +```python +f.g # = [df/dx, df/dy] +>>> array([-4., 1.]) +``` +Get the second order derivatives of `f`: +```python +f.hm() # = [[d^2 f/ dx**2 , d^2 f/(dx*dy)], + # [d^2 f/(dx*dy), d^2 f/ dy**2 ]] +>>> array([[-2.66666667, 1.33333333], + [ 1.33333333, -0.66666667]]) +``` +You can use numpy to perform vector and matrix operations. +Compute the nomalized cross product of two vectors `u = [1, 2, 2]` and `v = [4, 1, -1]` with hyper-dual numbers: +```python +import numpy as np +variables = hj.DDScalar.variables([1, 2, 2, + 4, 1, -1]) +u = np.array(variables[:3]) # = [1hj, 2hj, 2hj] +v = np.array(variables[3:]) # = [4hj, 1hj, -1hj] +normal = np.cross(u, v) +normal /= np.linalg.norm(normal) +normal +>>> array([-0.331042hj, 0.744845hj, -0.579324hj], dtype=object) +``` +The result is a three-dimensional numpy array containing hyper-dual numbers. +Get the value and derivatives of the x-component: +```python +normal[0].f +>>> -0.3310423554409472 +normal[0].g +>>> array([ 0.00453483, -0.01020336, 0.00793595, 0.07255723, -0.16325376, 0.12697515]) +normal[0].hm() +>>> array([[ 0.00434846, -0.01091775, 0.00647611, -0.0029818 , -0.01143025, -0.02335746], + [-0.01091775, 0.02711578, -0.01655522, 0.00444165, 0.03081974, 0.04858632], + [ 0.00647611, -0.01655522, 0.0093492 , -0.00295074, -0.02510461, -0.03690759], + [-0.0029818 , 0.00444165, -0.00295074, -0.02956956, 0.03025289, -0.01546811], + [-0.01143025, 0.03081974, -0.02510461, 0.03025289, 0.01355789, -0.02868433], + [-0.02335746, 0.04858632, -0.03690759, -0.01546811, -0.02868433, 0.03641839]]) +``` +## Reference +If you use HyperJet, please refer to the official GitHub repository: +```bibtex +@misc{HyperJet, + author = "Thomas Oberbichler", + title = "HyperJet", + howpublished = "\url{http://github.com/oberbichler/HyperJet}", +} +``` + +%package help +Summary: Development documents and examples for hyperjet +Provides: python3-hyperjet-doc +%description help +A header-only library for algorithmic differentiation with hyper-dual numbers. Written in C++17 with an extensive Python interface. +[![PyPI](https://img.shields.io/pypi/v/hyperjet)](https://pypi.org/project/hyperjet) [![DOI](https://zenodo.org/badge/165487832.svg)](https://zenodo.org/badge/latestdoi/165487832) [![Build Status](https://github.com/oberbichler/HyperJet/workflows/Python%20package/badge.svg?branch=master)](https://github.com/oberbichler/HyperJet/actions) ![PyPI - License](https://img.shields.io/pypi/l/hyperjet) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hyperjet) ![PyPI - Format](https://img.shields.io/pypi/format/hyperjet) +## Installation +``` +pip install hyperjet +``` +## Quickstart +Import the module: +```python +import hyperjet as hj +``` +Create a set of variables e.g. `x=3` and `y=6`: +```python +x, y = hj.variables([3, 6]) +``` +`x` and `y` are hyper-dual numbers. This is indicated by the postfix `hj`: +```python +x +>>> 3hj +``` +Get the value as a simple `float`: +```python +x.f +>>> 3 +``` +The hyper-dual number stores the derivatives as a numpy array. +Get the first order derivatives (Gradient) of a hyper-dual number: +```python +x.g # = [dx/dx, dx/dy] +>>> array([1., 0.]) +``` +Get the second order derivatives (Hessian matrix): +```python +x.hm() # = [[d^2 x/ dx**2 , d^2 x/(dx*dy)], + # [d^2 x/(dx*dy), d^2 x/ dy**2 ]] +>>> array([[0., 0.], + [0., 0.]]) +``` +For a simple variable these derivatives are trivial. +Now do some computations: +```python +f = (x * y) / (x - y) +f +>>> -6hj +``` +The result is again a hyper-dual number. +Get the first order derivatives of `f` with respect to `x` and `y`: +```python +f.g # = [df/dx, df/dy] +>>> array([-4., 1.]) +``` +Get the second order derivatives of `f`: +```python +f.hm() # = [[d^2 f/ dx**2 , d^2 f/(dx*dy)], + # [d^2 f/(dx*dy), d^2 f/ dy**2 ]] +>>> array([[-2.66666667, 1.33333333], + [ 1.33333333, -0.66666667]]) +``` +You can use numpy to perform vector and matrix operations. +Compute the nomalized cross product of two vectors `u = [1, 2, 2]` and `v = [4, 1, -1]` with hyper-dual numbers: +```python +import numpy as np +variables = hj.DDScalar.variables([1, 2, 2, + 4, 1, -1]) +u = np.array(variables[:3]) # = [1hj, 2hj, 2hj] +v = np.array(variables[3:]) # = [4hj, 1hj, -1hj] +normal = np.cross(u, v) +normal /= np.linalg.norm(normal) +normal +>>> array([-0.331042hj, 0.744845hj, -0.579324hj], dtype=object) +``` +The result is a three-dimensional numpy array containing hyper-dual numbers. +Get the value and derivatives of the x-component: +```python +normal[0].f +>>> -0.3310423554409472 +normal[0].g +>>> array([ 0.00453483, -0.01020336, 0.00793595, 0.07255723, -0.16325376, 0.12697515]) +normal[0].hm() +>>> array([[ 0.00434846, -0.01091775, 0.00647611, -0.0029818 , -0.01143025, -0.02335746], + [-0.01091775, 0.02711578, -0.01655522, 0.00444165, 0.03081974, 0.04858632], + [ 0.00647611, -0.01655522, 0.0093492 , -0.00295074, -0.02510461, -0.03690759], + [-0.0029818 , 0.00444165, -0.00295074, -0.02956956, 0.03025289, -0.01546811], + [-0.01143025, 0.03081974, -0.02510461, 0.03025289, 0.01355789, -0.02868433], + [-0.02335746, 0.04858632, -0.03690759, -0.01546811, -0.02868433, 0.03641839]]) +``` +## Reference +If you use HyperJet, please refer to the official GitHub repository: +```bibtex +@misc{HyperJet, + author = "Thomas Oberbichler", + title = "HyperJet", + howpublished = "\url{http://github.com/oberbichler/HyperJet}", +} +``` + +%prep +%autosetup -n hyperjet-1.4.3 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-hyperjet -f filelist.lst +%dir %{python3_sitearch}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot - 1.4.3-1 +- Package Spec generated -- cgit v1.2.3