Created
May 26, 2020 10:56
-
-
Save Rmano/e7c48d09be4cea71ea5e7d3b20f9808b to your computer and use it in GitHub Desktop.
Tests for fpu magic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[border=10pt]{standalone} | |
\usepackage[RPvoltages]{circuitikz} | |
\usetikzlibrary{fpu} | |
\makeatletter | |
\pgfqkeys{/pgf}{ | |
fpu/install only/.code={ | |
\pgfmath@warning{The key `/pgf/fpu/install only' is experimental and might % | |
change or disappear at any point!}% | |
\edef\pgf@list{#1}% | |
\pgfutil@for\pgf@temp:=\pgf@list\do{% | |
\expandafter\pgfmath@float@install@singlefunction\expandafter{% | |
\romannumeral-`0\expandafter\pgfutil@trimspaces\expandafter{\pgf@temp}}% | |
}% | |
}, | |
} | |
\def\pgfmath@float@install@singlefunction#1{% | |
\ifcsname pgfmath@function@#1\endcsname\else | |
\pgfmath@error{The function `#1' does not exist}{}% | |
\fi | |
\pgfmath@toks={}% | |
\pgfmathloop | |
\ifnum\pgfmathcounter>\csname pgfmath@operation@#1@arity\endcsname\relax% | |
\else | |
\expandafter\pgfmath@addto@toks\expandafter{\pgfmath@char@hash}% | |
\expandafter\pgfmath@addto@toks\expandafter{\pgfmathcounter}% | |
\repeatpgfmathloop | |
\edef\pgfmath@head{\noexpand\def\expandafter\noexpand\csname pgfmath#1@\endcsname\the\pgfmath@toks}% | |
\pgfmath@toks={}% | |
\def\pgfmath@arguments{}% | |
\pgfmathloop | |
\ifnum\pgfmathcounter>\csname pgfmath@operation@#1@arity\endcsname\relax% | |
\else | |
\pgfmath@addto@toks{\pgfmathfloatparsenumber}% | |
\expandafter\expandafter\expandafter\pgfmath@addto@toks | |
\expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter | |
{\expandafter\pgfmath@char@hash\pgfmathcounter}}% | |
\pgfmath@addto@toks{\let}% | |
\expandafter\pgfmath@addto@toks\expandafter{% | |
\csname pgfmath@argument@\pgfmathcounter\endcsname=\pgfmathresult}% | |
\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter | |
\pgfmath@arguments\expandafter\expandafter\expandafter{\expandafter | |
\pgfmath@arguments\expandafter{\csname pgfmath@argument@\pgfmathcounter\endcsname}}% | |
\repeatpgfmathloop | |
\expandafter\pgfmath@addto@toks\expandafter{\csname pgfmathfloat#1@\expandafter\endcsname\pgfmath@arguments}% | |
\pgfmath@addto@toks{\pgfmathfloattofixed{\pgfmathresult}}% | |
\edef\pgfmath@body{{\the\pgfmath@toks}}% | |
\expandafter\pgfmath@head\pgfmath@body | |
} | |
\makeatother | |
\begin{document} | |
\begin{circuitikz}[scale=1.2, transform shape] | |
\pgfkeys{/pgf/fpu/install only={reciprocal}} | |
% | |
% this fails with Illegal unit of measure | |
%\pgfkeys{/pgf/fpu/install only={divide}} | |
\draw (12,1) to [battery2, v_=$V_{cc}$] ++(0,2); | |
\end{circuitikz} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment