Fused multiply-add (with a single rounding) for Python.

Overview

pyfma

Fused multiply-add for Python.

PyPi Version PyPI pyversions GitHub stars PyPi downloads

Discord

gh-actions codecov Code style: black

Fused multiply-add computes (x*y) + z with a single rounding. Useful for dot products, matrix multiplications, polynomial evaluations (e.g., with Horner's rule), Newton's method for evaluating functions, convolutions, artificial neural networks etc.

Use as

import pyfma

out = pyfma.fma(3.0, 2.0, 1.0)  # 3.0*2.0 + 1.0 = 7.0

Also works with NumPy inputs:

import numpy
import pyfma

x = numpy.random.rand(3, 4, 5)
y = numpy.random.rand(3, 4, 5)
z = numpy.random.rand(3, 4, 5)

out = pyfma.fma(x, y, z)

Built with pybind11.

Caution The C/C++ implementation of FMA in MS Windows is reportedly broken. Use with care.

Installation

pyfma can be installed from the Python Package Index, so with

pip install pyfma

you can install/upgrade.

Manual installation

For manual installation (if you're a developer or just really keen on getting the bleeding edge version of pyfma), there are two possibilities:

  • Get the sources, do pip install .. This does the trick most the time.
  • As a fallback, there's a CMake-based installation. Simply go cmake /path/to/sources/ and make.

Testing

To run the pyfma unit tests, check out this repository and type

tox
You might also like...
A Kodi add-on for watching content hosted on PeerTube.

A Kodi add-on for watching content hosted on PeerTube. This add-on is under development so only basic features work, and you're welcome to improve it.

A script to add issues to a project in Github based on label or status.

Add Github Issues to Project (Beta) A python script to move Github issues to a next-gen (beta) Github Project Getting Started These instructions will

The repository for AnyMacro: a Fusion360 Add-In
The repository for AnyMacro: a Fusion360 Add-In

AnyMacro AnyMacro is an Autodesk® Fusion 360™ add-in for chaining multiple commands in a row to form Macros. Macros are created from a set of commands

TB Set color display - Add-on for Blender to set multiple objects and material Display Color at once.
TB Set color display - Add-on for Blender to set multiple objects and material Display Color at once.

TB_Set_color_display Add-on for Blender with operations to transfer name between object, data, materials and action names Set groups of object's or ma

This repo contains scripts that add functionality to xbar.
This repo contains scripts that add functionality to xbar.

xbar-custom-plugins This repo contains scripts that add functionality to xbar. Usage You have to add scripts to xbar plugin folder. If you don't find

A clipboard where a user can add and retrieve multiple items to and from (resp) from the clipboard cache.

A clipboard where a user can add and retrieve multiple items to and from (resp) from the clipboard cache.

Ikaros is a free financial library built in pure python that can be used to get information for single stocks, generate signals and build prortfolios

Ikaros is a free financial library built in pure python that can be used to get information for single stocks, generate signals and build prortfolios

A simple single-color identicon generator

Identicons What are identicons? Setup: git clone https://github.com/vjdad4m/identicons.git cd identicons pip3 install -r requirements.txt chmod +x

Comments
  • Build failure on macOS Catalina

    Build failure on macOS Catalina

    I have Python 3.8 installed on my Mac via MacPorts. In a new venv, doing pip install pyfma results in a failure, and looking at the errors it is caused by failing to include the flag -std=c++11. Installing requires CFLAGS='-std=c++11' pip install pyfma. My exact compiler version is Apple clang version 12.0.0 (clang-1200.0.32.2), which is the compiler that comes with Xcode 12.

    opened by SerpentChris 3
  • fma32

    fma32

    Hi,

    Thank you for the great tool. I am curious whether it is difficult to add support of FMA operation for float numbers additionally to the current double implementation. It would be really helpful for testing and debugging various numerical algorithms in plenty of software using float due to speed reasons.

    Cheers

    opened by Vutshi 1
  • Unmarked dependency on numpy.

    Unmarked dependency on numpy.

    Steps to reproduce:

    1. Make and activate a fresh virtualenv.
    2. Install pyfma via pip
    3. Run the command python -c "import pyfma; pyfma.fma(1,2,3)"

    The result is ModuleNotFoundError: No module named 'numpy'.

    What I expect is to either be able to use pyfma without numpy, or for pyfma to automatically have pip download and install numpy when I install pyfma. I'm not an expert at setuptools but I think the first case requires making numpy an optional dependency, while the second case requires making numpy a required dependency.

    opened by SerpentChris 0
Releases(0.1.6)
Owner
Nico Schlömer
Mathematics, numerical analysis, scientific computing, Python. Always interested in new problems.
Nico Schlömer
Blender Add-on to Add Metal Materials to Your Scene

Blender QMM (Quick Metal Materials) Blender Addon to Add Metal Materials to Your Scene Installation Download the latest ZIP from Releases. Usage This

Don Schnitzius 27 Dec 26, 2022
Craxk is a SINGLE AND NON-REPLICABLE Hash that uses data from the hardware where it is executed to form a hash that can only be reproduced by a single machine.

What is Craxk ? Craxk is a UNIQUE AND NON-REPLICABLE Hash that uses data from the hardware where it is executed to form a hash that can only be reprod

null 5 Jun 19, 2021
Enhanced version of blender's bvh add-on with more settings supported. The bvh's rest pose should have the same handedness as the armature while could use a different up/forward definiton.

Enhanced bvh add-on (importer/exporter) for blender Enhanced bvh add-on (importer/exporter) for blender Enhanced bvh importer Enhanced bvh exporter Ho

James Zhao 16 Dec 20, 2022
Yunqi Chen 7 Oct 30, 2022
Add-In for Blender to automatically save files when rendering

Autosave - Render: Automatically save .blend, .png and readme.txt files when rendering with Blender Purpose This Blender Add-On provides an easy way t

Volker 9 Aug 10, 2022
Starscape is a Blender add-on for adding stars to the background of a scene.

Starscape Starscape is a Blender add-on for adding stars to the background of a scene. Features The add-on provides the following features: Procedural

Marco Rossini 5 Jun 24, 2022
Reload all Blender add-on modules

Reload-Addon This add-on creates a list of the modules that the add-on selected in the drop-down menu contains and reloads them with the keyboard shor

null 2 Dec 2, 2021
This an Anki add on that automatically converts Notion notes into Anki flash cards. Currently in development!

NotionFlash This is an Anki add on in development that will allow automatically convert your Notion study notes into Anki flash cards. The Anki deck c

Neeraj Patel 10 Oct 7, 2022
Blender Add-on That Provides Quick Access to Render Controls

Blender Render Buttons Blender Add-on That Provides Quick Access to Render Controls A Blender 3.0 compatablity update of Blender2.8x-RenderButton v0.0

Don Schnitzius 3 Oct 18, 2022
Add your recently blog and douban states in your GitHub Profile

Add your recently blog and douban states in your GitHub Profile

Bingjie Yan 4 Dec 12, 2022