1085 lines
No EOL
112 KiB
HTML
1085 lines
No EOL
112 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="description" content="RPN calculator in modern Fortran">
|
|
<meta name="author" content="sgeard" >
|
|
<link rel="icon" href="../favicon.png">
|
|
|
|
<title>apply_command – hp</title>
|
|
|
|
<link href="../css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="../css/pygments.css" rel="stylesheet">
|
|
<link href="../css/font-awesome.min.css" rel="stylesheet">
|
|
<link href="../css/local.css" rel="stylesheet">
|
|
<link href="../tipuesearch/tipuesearch.css" rel="stylesheet">
|
|
|
|
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
|
<!--[if lt IE 9]>
|
|
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
|
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
|
<![endif]-->
|
|
|
|
<script src="../js/jquery-2.1.3.min.js"></script>
|
|
<script src="../js/svg-pan-zoom.min.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<!-- Fixed navbar -->
|
|
<nav class="navbar navbar-inverse navbar-fixed-top">
|
|
<div class="container">
|
|
<div class="navbar-header">
|
|
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
|
<span class="sr-only">Toggle navigation</span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
</button>
|
|
<a class="navbar-brand" href="../index.html">hp </a>
|
|
</div>
|
|
<div id="navbar" class="navbar-collapse collapse">
|
|
<ul class="nav navbar-nav">
|
|
<li class="dropdown hidden-xs visible-sm visible-md hidden-lg">
|
|
<a href="#" class="dropdown-toggle"
|
|
data-toggle="dropdown" role="button"
|
|
aria-haspopup="true"
|
|
aria-expanded="false">Contents <span class="caret"></span></a>
|
|
<ul class="dropdown-menu">
|
|
<li><a href="../lists/files.html">Source Files</a></li>
|
|
<li><a href="../lists/modules.html">Modules</a></li>
|
|
<li><a href="../lists/procedures.html">Procedures</a></li>
|
|
<li><a href="../lists/absint.html">Abstract Interfaces</a></li>
|
|
<li><a href="../lists/types.html">Derived Types</a></li>
|
|
<li><a href="../lists/programs.html">Programs</a></li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/files.html">Source Files</a></li>
|
|
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/modules.html">Modules</a></li>
|
|
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/procedures.html">Procedures</a></li>
|
|
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/absint.html">Abstract Interfaces</a></li>
|
|
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/types.html">Derived Types</a></li>
|
|
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/programs.html">Programs</a></li>
|
|
</ul>
|
|
<form action="../search.html" class="navbar-form navbar-right" role="search">
|
|
<div class="form-group">
|
|
<input type="text" class="form-control" placeholder="Search" name="q" id="tipue_search_input" autocomplete="off" required>
|
|
</div>
|
|
<!--
|
|
<button type="submit" class="btn btn-default">Submit</button>
|
|
-->
|
|
</form>
|
|
</div><!--/.nav-collapse -->
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="container">
|
|
<div class="row">
|
|
<h1>apply_command
|
|
<small>Subroutine</small>
|
|
|
|
</h1>
|
|
<div class="row" id="info-bar">
|
|
<div class="col-lg-12">
|
|
<div class="well well-sm">
|
|
<ul class="list-inline" style="margin-bottom:0px;display:inline">
|
|
|
|
<li id="statements"><i class="fa fa-list-ol"></i>
|
|
<a data-toggle="tooltip"
|
|
data-placement="bottom" data-html="true"
|
|
title=" 3.4% of total for procedures.">386 statements</a>
|
|
</li>
|
|
|
|
<li id="source-file">
|
|
<i class="fa fa-code"></i>
|
|
<a href="../src/main.f90"> Source File</a>
|
|
</li>
|
|
</ul>
|
|
<ol class="breadcrumb in-well text-right">
|
|
<li><a href='../sourcefile/main.f90.html'>main.f90</a></li>
|
|
<li><a href='../program/hp15c.html'>hp15c</a></li>
|
|
<li class="active">apply_command</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
$(function () {
|
|
$('[data-toggle="tooltip"]').tooltip()
|
|
})
|
|
</script>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-3 hidden-xs hidden-sm visible-md visible-lg">
|
|
<div id="sidebar">
|
|
<h3>Contents</h3>
|
|
|
|
<div class="panel panel-primary">
|
|
<div class="panel-heading text-left">
|
|
<h3 class="panel-title">
|
|
<a data-toggle="collapse" href="#vars-0">Variables</a>
|
|
</h3>
|
|
</div>
|
|
<div id="vars-0" class="panel-collapse collapse">
|
|
<div class="list-group">
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-ang">ang</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-comma">comma</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-idx~5">idx</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-im">im</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-is_cart~2">is_cart</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-lang~2">lang</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-m~2">m</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-r~67">r</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-tmp_seq">tmp_seq</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-u">u</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-us">us</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-z~6">z</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-zs">zs</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="panel panel-primary">
|
|
<div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
|
|
<div class="list-group">
|
|
<a class="list-group-item" href="../proc/apply_command.html#src">apply_command</a>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-9" id='text'>
|
|
<h2> subroutine apply_command(command, ok)
|
|
</h2>
|
|
<div class="panel panel-default">
|
|
<div class="panel-heading">
|
|
<h3 class="panel-title">Uses</h3>
|
|
</div>
|
|
<ul class="list-group">
|
|
<li class="list-group-item">
|
|
<ul class="list-inline">
|
|
<li><a href="http://fortranwiki.org/fortran/show/ieee_arithmetic">ieee_arithmetic</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
|
|
|
|
<h3>Arguments</h3>
|
|
<table class="table table-striped varlist">
|
|
<thead>
|
|
<tr>
|
|
<th>Type</th>
|
|
<th>Intent</th><th>Optional</th> <th>Attributes</th>
|
|
<th></th>
|
|
<th>Name</th>
|
|
<th></th>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>
|
|
<span class="anchor" id="variable-command~3"></span>
|
|
character,
|
|
</td>
|
|
<td>intent(in)</td>
|
|
<td></td> <td>
|
|
|
|
</td>
|
|
<td>::</td>
|
|
<td><strong>command</strong></td>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<span class="anchor" id="variable-ok~2"></span>
|
|
logical,
|
|
</td>
|
|
<td>intent(out)</td>
|
|
<td></td> <td>
|
|
|
|
</td>
|
|
<td>::</td>
|
|
<td><strong>ok</strong></td>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<br>
|
|
|
|
<section class="visible-xs visible-sm hidden-md">
|
|
<h3>Contents</h3>
|
|
|
|
<div class="panel panel-primary">
|
|
<div class="panel-heading text-left">
|
|
<h3 class="panel-title">
|
|
<a data-toggle="collapse" href="#vars-1">Variables</a>
|
|
</h3>
|
|
</div>
|
|
<div id="vars-1" class="panel-collapse collapse">
|
|
<div class="list-group">
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-ang">ang</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-comma">comma</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-idx~5">idx</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-im">im</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-is_cart~2">is_cart</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-lang~2">lang</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-m~2">m</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-r~67">r</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-tmp_seq">tmp_seq</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-u">u</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-us">us</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-z~6">z</a>
|
|
<a class="list-group-item" href="../proc/apply_command.html#variable-zs">zs</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="panel panel-primary">
|
|
<div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
|
|
<div class="list-group">
|
|
<a class="list-group-item" href="../proc/apply_command.html#src">apply_command</a>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</section>
|
|
<br class="visible-xs visible-sm hidden-md">
|
|
|
|
|
|
<section>
|
|
<h2>Variables</h2>
|
|
<table class="table table-striped varlist">
|
|
<thead>
|
|
<tr>
|
|
<th>Type</th>
|
|
<th>Visibility</th> <th>Attributes</th>
|
|
<th></th>
|
|
<th>Name</th>
|
|
<th></th><th>Initial</th> <th></th>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>
|
|
<span class="anchor" id="variable-ang"></span>
|
|
real(kind=8),
|
|
</td>
|
|
<td>public</td>
|
|
<td>
|
|
|
|
</td>
|
|
<td>::</td>
|
|
<td><strong>ang</strong></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<span class="anchor" id="variable-comma"></span>
|
|
character(len=1),
|
|
</td>
|
|
<td>public</td>
|
|
<td>
|
|
|
|
</td>
|
|
<td>::</td>
|
|
<td><strong>comma</strong></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<span class="anchor" id="variable-idx~5"></span>
|
|
integer,
|
|
</td>
|
|
<td>public</td>
|
|
<td>
|
|
|
|
</td>
|
|
<td>::</td>
|
|
<td><strong>idx</strong></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<span class="anchor" id="variable-im"></span>
|
|
real(kind=8),
|
|
</td>
|
|
<td>public</td>
|
|
<td>
|
|
|
|
</td>
|
|
<td>::</td>
|
|
<td><strong>im</strong></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<span class="anchor" id="variable-is_cart~2"></span>
|
|
logical,
|
|
</td>
|
|
<td>public</td>
|
|
<td>
|
|
|
|
</td>
|
|
<td>::</td>
|
|
<td><strong>is_cart</strong></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<span class="anchor" id="variable-lang~2"></span>
|
|
character(len=5),
|
|
</td>
|
|
<td>public,</td>
|
|
<td>
|
|
parameter
|
|
</td>
|
|
<td>::</td>
|
|
<td><strong>lang</strong>(2)</td>
|
|
<td> =</td>
|
|
<td>['POINT', 'COMMA']</td>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<span class="anchor" id="variable-m~2"></span>
|
|
integer,
|
|
</td>
|
|
<td>public</td>
|
|
<td>
|
|
|
|
</td>
|
|
<td>::</td>
|
|
<td><strong>m</strong></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<span class="anchor" id="variable-r~67"></span>
|
|
real(kind=8),
|
|
</td>
|
|
<td>public</td>
|
|
<td>
|
|
|
|
</td>
|
|
<td>::</td>
|
|
<td><strong>r</strong></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<span class="anchor" id="variable-tmp_seq"></span>
|
|
real(kind=8),
|
|
</td>
|
|
<td>public,</td>
|
|
<td>
|
|
allocatable
|
|
</td>
|
|
<td>::</td>
|
|
<td><strong>tmp_seq</strong>(:)</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<span class="anchor" id="variable-u"></span>
|
|
complex(kind=8),
|
|
</td>
|
|
<td>public</td>
|
|
<td>
|
|
|
|
</td>
|
|
<td>::</td>
|
|
<td><strong>u</strong></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<span class="anchor" id="variable-us"></span>
|
|
type(<a href='../type/rpn_t.html'>rpn_t</a>),
|
|
</td>
|
|
<td>public</td>
|
|
<td>
|
|
|
|
</td>
|
|
<td>::</td>
|
|
<td><strong>us</strong></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<span class="anchor" id="variable-z~6"></span>
|
|
complex(kind=8),
|
|
</td>
|
|
<td>public</td>
|
|
<td>
|
|
|
|
</td>
|
|
<td>::</td>
|
|
<td><strong>z</strong></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<span class="anchor" id="variable-zs"></span>
|
|
type(<a href='../type/rpn_t.html'>rpn_t</a>),
|
|
</td>
|
|
<td>public</td>
|
|
<td>
|
|
|
|
</td>
|
|
<td>::</td>
|
|
<td><strong>zs</strong></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
</section>
|
|
<br>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section>
|
|
<h2><span class="anchor" id="src"></span>Source Code</h2>
|
|
<div class="highlight"><pre><span></span><span class="w"> </span><span class="k">subroutine </span><span class="n">apply_command</span><span class="p">(</span><span class="n">command</span><span class="p">,</span><span class="w"> </span><span class="n">ok</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">use</span><span class="p">,</span><span class="w"> </span><span class="k">intrinsic</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">ieee_arithmetic</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">implicit none</span>
|
|
<span class="k"> </span><span class="kt">character</span><span class="p">(</span><span class="o">*</span><span class="p">),</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">command</span><span class="w"></span>
|
|
<span class="w"> </span><span class="kt">logical</span><span class="p">,</span><span class="w"> </span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">ok</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="kt">real</span><span class="p">(</span><span class="mi">8</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="n">im</span><span class="p">,</span><span class="w"> </span><span class="n">ang</span><span class="w"></span>
|
|
<span class="w"> </span><span class="kt">complex</span><span class="p">(</span><span class="mi">8</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">u</span><span class="p">,</span><span class="w"> </span><span class="n">z</span><span class="w"></span>
|
|
<span class="w"> </span><span class="kt">real</span><span class="p">(</span><span class="mi">8</span><span class="p">),</span><span class="w"> </span><span class="k">allocatable</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">tmp_seq</span><span class="p">(:)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">type</span><span class="p">(</span><span class="n">rpn_t</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">us</span><span class="p">,</span><span class="w"> </span><span class="n">zs</span><span class="w"></span>
|
|
<span class="w"> </span><span class="kt">logical</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">is_cart</span><span class="w"></span>
|
|
<span class="w"> </span><span class="kt">integer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">m</span><span class="p">,</span><span class="w"> </span><span class="n">idx</span><span class="w"></span>
|
|
<span class="w"> </span><span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">comma</span><span class="w"></span>
|
|
<span class="w"> </span><span class="kt">character</span><span class="p">(</span><span class="mi">5</span><span class="p">),</span><span class="w"> </span><span class="k">parameter</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">lang</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="s1">'POINT'</span><span class="p">,</span><span class="s1">'COMMA'</span><span class="p">]</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="n">ok</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">true</span><span class="p">.</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nb">len_trim</span><span class="p">(</span><span class="n">command</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> return</span>
|
|
<span class="k"> end if</span>
|
|
<span class="k"> </span>
|
|
<span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="n">verbosity</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> write</span><span class="p">(</span><span class="o">*</span><span class="p">,</span><span class="s1">'(a)'</span><span class="p">)</span><span class="w"> </span><span class="s1">'Applying: '</span><span class="o">//</span><span class="n">command</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> </span>
|
|
<span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="n">in_sequence</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="n">command</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s1">'}'</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">in_sequence</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">complex_mode</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">tmp_cmode</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">calculate_stats</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">else</span><span class="w"></span>
|
|
<span class="w"> </span><span class="c">! All elements must be the same so either all x or all x,y</span>
|
|
<span class="w"> </span><span class="n">idx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">index</span><span class="p">(</span><span class="n">command</span><span class="p">,</span><span class="s1">','</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">n_seq</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">seq_is_x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">idx</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="n">seq_is_x</span><span class="w"> </span><span class="p">.</span><span class="n">neqv</span><span class="p">.</span><span class="w"> </span><span class="p">(</span><span class="n">idx</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="p">))</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> goto</span><span class="w"> </span><span class="mi">901</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="n">seq_is_x</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> read</span><span class="p">(</span><span class="n">command</span><span class="p">,</span><span class="o">*</span><span class="p">,</span><span class="n">err</span><span class="o">=</span><span class="mi">901</span><span class="p">)</span><span class="w"> </span><span class="n">r</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">im</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else</span>
|
|
<span class="k"> read</span><span class="p">(</span><span class="n">command</span><span class="p">(</span><span class="mi">1</span><span class="p">:</span><span class="n">idx</span><span class="o">-</span><span class="mi">1</span><span class="p">),</span><span class="o">*</span><span class="p">,</span><span class="n">err</span><span class="o">=</span><span class="mi">901</span><span class="p">)</span><span class="w"> </span><span class="n">r</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">read</span><span class="p">(</span><span class="n">command</span><span class="p">(</span><span class="n">idx</span><span class="o">+</span><span class="mi">1</span><span class="p">:</span><span class="nb">len</span><span class="p">(</span><span class="n">command</span><span class="p">)),</span><span class="o">*</span><span class="p">,</span><span class="n">err</span><span class="o">=</span><span class="mi">901</span><span class="p">)</span><span class="w"> </span><span class="n">im</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span><span class="w"></span>
|
|
<span class="w"> </span><span class="c">! Initial allocation</span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">n_seq</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">.</span><span class="nb">and</span><span class="p">.</span><span class="w"> </span><span class="p">.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="nb">allocated</span><span class="p">(</span><span class="n">x_seq</span><span class="p">))</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> allocate</span><span class="p">(</span><span class="n">x_seq</span><span class="p">(</span><span class="mi">10</span><span class="p">))</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="n">seq_is_x</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> allocate</span><span class="p">(</span><span class="n">y_seq</span><span class="p">(</span><span class="mi">10</span><span class="p">))</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> end if</span>
|
|
<span class="k"> </span>
|
|
<span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="n">n_seq</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">size</span><span class="p">(</span><span class="n">x_seq</span><span class="p">))</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">n_seq</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">n_seq</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else</span><span class="w"></span>
|
|
<span class="w"> </span><span class="c">! Expand array</span>
|
|
<span class="w"> </span><span class="k">allocate</span><span class="p">(</span><span class="n">tmp_seq</span><span class="p">(</span><span class="n">n_seq</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">10</span><span class="p">))</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">tmp_seq</span><span class="p">(</span><span class="mi">1</span><span class="p">:</span><span class="n">n_seq</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x_seq</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="nb">move_alloc</span><span class="p">(</span><span class="n">tmp_seq</span><span class="p">,</span><span class="w"> </span><span class="n">x_seq</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="n">seq_is_x</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> allocate</span><span class="p">(</span><span class="n">tmp_seq</span><span class="p">(</span><span class="n">n_seq</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">10</span><span class="p">))</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">tmp_seq</span><span class="p">(</span><span class="mi">1</span><span class="p">:</span><span class="n">n_seq</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">y_seq</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="nb">move_alloc</span><span class="p">(</span><span class="n">tmp_seq</span><span class="p">,</span><span class="w"> </span><span class="n">y_seq</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> end if</span>
|
|
<span class="k"> </span><span class="n">x_seq</span><span class="p">(</span><span class="n">n_seq</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">r</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="n">seq_is_x</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">y_seq</span><span class="p">(</span><span class="n">n_seq</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">im</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="n">verbosity</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> print</span><span class="w"> </span><span class="o">*</span><span class="p">,</span><span class="n">x_seq</span><span class="p">(</span><span class="mi">1</span><span class="p">:</span><span class="n">n_seq</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> end if</span>
|
|
<span class="k"> return</span>
|
|
<span class="k"> end if</span>
|
|
<span class="k"> </span>
|
|
<span class="k"> select case</span><span class="p">(</span><span class="n">command</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'q'</span><span class="p">,</span><span class="s1">'quit'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">ok</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">false</span><span class="p">.</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">return</span>
|
|
<span class="k"> </span>
|
|
<span class="k"> case</span><span class="p">(</span><span class="s1">'='</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">ok</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">false</span><span class="p">.</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">return</span>
|
|
<span class="k"> </span>
|
|
<span class="k"> case</span><span class="p">(</span><span class="s1">'{'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="c">! Start sequence</span>
|
|
<span class="w"> </span><span class="n">in_sequence</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">n_seq</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">tmp_cmode</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">complex_mode</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">complex_mode</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">false</span><span class="p">.</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stats</span><span class="p">%</span><span class="n">clear</span><span class="p">()</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'--'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">chs_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'^'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">push</span><span class="p">(</span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'+'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_binary</span><span class="p">(</span><span class="n">add_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'-'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_binary</span><span class="p">(</span><span class="n">subtract_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'*'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_binary</span><span class="p">(</span><span class="n">multiply_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'/'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_binary</span><span class="p">(</span><span class="n">divide_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'^x'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_binary</span><span class="p">(</span><span class="n">power_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'^/x'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="c">! Only raising to a real power is supported</span>
|
|
<span class="w"> </span><span class="n">zs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">zs</span><span class="p">%</span><span class="n">is_real</span><span class="p">())</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> call </span><span class="n">invoke_binary</span><span class="p">(</span><span class="n">root_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else</span>
|
|
<span class="k"> goto</span><span class="w"> </span><span class="mi">901</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> </span>
|
|
<span class="k"> case</span><span class="p">(</span><span class="s1">'>'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">next_root_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'<'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">previous_root_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'%'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_binary</span><span class="p">(</span><span class="n">percent_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'xy'</span><span class="p">,</span><span class="s1">'XY'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">swap</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'R'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">rotate_down</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'r'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">rotate_up</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'CLA'</span><span class="p">,</span><span class="s1">'cla'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">clear</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">mem</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">rpn_t</span><span class="p">()</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stats</span><span class="p">%</span><span class="n">clear</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'CL'</span><span class="p">,</span><span class="s1">'cl'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">clear</span><span class="w"></span>
|
|
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'CLX'</span><span class="p">,</span><span class="s1">'clx'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">set</span><span class="p">(</span><span class="n">rpn_t</span><span class="p">())</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'_'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">complex_mode</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">conj_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">endif</span>
|
|
|
|
<span class="k"> case</span><span class="p">(</span><span class="s1">'len'</span><span class="p">,</span><span class="s1">'||'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">complex_mode</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">len_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="c">! Length is always reported as (x,0) and marked is_cartesian</span>
|
|
<span class="w"> </span><span class="n">zs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">zs</span><span class="p">%</span><span class="n">set_value</span><span class="p">(</span><span class="n">is_cartesian</span><span class="o">=</span><span class="p">.</span><span class="n">true</span><span class="p">.)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">set</span><span class="p">(</span><span class="n">zs</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else</span>
|
|
<span class="k"> </span><span class="n">zs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">z</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">zs</span><span class="p">%</span><span class="n">get_value</span><span class="p">()</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">us</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">u</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">us</span><span class="p">%</span><span class="n">get_value</span><span class="p">()</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">zs</span><span class="p">%</span><span class="n">set_value</span><span class="p">(</span><span class="nb">cmplx</span><span class="p">(</span><span class="nb">hypot</span><span class="p">(</span><span class="n">z</span><span class="p">%</span><span class="n">re</span><span class="p">,</span><span class="n">u</span><span class="p">%</span><span class="n">re</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="mi">8</span><span class="p">))</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">set</span><span class="p">(</span><span class="n">zs</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> </span>
|
|
<span class="k"> case</span><span class="p">(</span><span class="s1">'split'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="n">complex_mode</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">zs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">pop</span><span class="p">()</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">zs</span><span class="p">%</span><span class="n">get_value</span><span class="p">()</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">x</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">floor</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else</span>
|
|
<span class="k"> </span><span class="n">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">ceiling</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> </span><span class="n">im</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">r</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">push</span><span class="p">(</span><span class="n">im</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">push</span><span class="p">(</span><span class="n">r</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> </span>
|
|
<span class="k"> case</span><span class="p">(</span><span class="s1">'int'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="n">complex_mode</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">zs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">zs</span><span class="p">%</span><span class="n">get_value</span><span class="p">()</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">x</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">floor</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else</span>
|
|
<span class="k"> </span><span class="n">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">ceiling</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> call </span><span class="n">zs</span><span class="p">%</span><span class="n">set_value</span><span class="p">(</span><span class="nb">cmplx</span><span class="p">(</span><span class="n">r</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">8</span><span class="p">))</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">set</span><span class="p">(</span><span class="n">zs</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> </span>
|
|
<span class="k"> case</span><span class="p">(</span><span class="s1">'nint'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="n">complex_mode</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">zs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">zs</span><span class="p">%</span><span class="n">get_value</span><span class="p">()</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">nint</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nb">mod</span><span class="p">(</span><span class="n">r</span><span class="p">,</span><span class="mf">2.0d0</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">r</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> call </span><span class="n">zs</span><span class="p">%</span><span class="n">set_value</span><span class="p">(</span><span class="nb">cmplx</span><span class="p">(</span><span class="n">r</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">8</span><span class="p">))</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">set</span><span class="p">(</span><span class="n">zs</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> </span>
|
|
<span class="k"> case</span><span class="p">(</span><span class="s1">'rem'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="w"> </span><span class="n">complex_mode</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">zs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">zs</span><span class="p">%</span><span class="n">get_value</span><span class="p">()</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">x</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">floor</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else</span>
|
|
<span class="k"> </span><span class="n">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">ceiling</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> </span><span class="n">im</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">r</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">zs</span><span class="p">%</span><span class="n">set_value</span><span class="p">(</span><span class="nb">cmplx</span><span class="p">(</span><span class="n">im</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">8</span><span class="p">))</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">set</span><span class="p">(</span><span class="n">zs</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> </span>
|
|
<span class="k"> case</span><span class="p">(</span><span class="s1">'drop'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">zs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">pop</span><span class="p">()</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'ri'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="c">! Swap real and imaginary parts</span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">complex_mode</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">swap_real_imaginary_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
|
|
<span class="k"> case</span><span class="p">(</span><span class="s1">'to_pol'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="c">! Convert x + iy to r + i theta</span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">complex_mode</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">zs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">set</span><span class="p">(</span><span class="n">to_polar</span><span class="p">(</span><span class="n">zs</span><span class="p">))</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
|
|
<span class="k"> case</span><span class="p">(</span><span class="s1">'to_cart'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="c">! Convert (r,theta) to (x,y)</span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">complex_mode</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">zs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">set</span><span class="p">(</span><span class="n">to_cartesian</span><span class="p">(</span><span class="n">zs</span><span class="p">))</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> </span>
|
|
<span class="k"> case</span><span class="p">(</span><span class="s1">'1/'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">reciprocal_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'^2'</span><span class="p">,</span><span class="s1">'sq'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">power_2_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'^/2'</span><span class="p">,</span><span class="s1">'sqrt'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">sqrt_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'^3'</span><span class="p">,</span><span class="s1">'cb'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">power_3_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'^/3'</span><span class="p">,</span><span class="s1">'cbrt'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">cbrt_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'^*2'</span><span class="p">,</span><span class="s1">'alog2'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">exp_2_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'^*10'</span><span class="p">,</span><span class="s1">'alog10'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">exp_10_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'exp'</span><span class="p">,</span><span class="s1">'alog'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">exp_e_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'ln'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">ln_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'log2'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">log2_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'lg'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">lg_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'sinh'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">hsine_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'cosh'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">hcosine_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'tanh'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">htangent_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'sin'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">sine_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'cos'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">cosine_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'tan'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">tangent_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'asin'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">asine_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'asinh'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">ahsine_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'acos'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">acosine_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'acosh'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">ahcosine_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'atan'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">atangent_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'atanh'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">ahtangent_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'atan2'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_binary</span><span class="p">(</span><span class="n">atangent2_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'gamma'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">gamma_fr</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'!'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">zs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">zs</span><span class="p">%</span><span class="n">is_positive_real</span><span class="p">())</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> call </span><span class="n">invoke_unary</span><span class="p">(</span><span class="n">fact_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else</span>
|
|
<span class="k"> goto</span><span class="w"> </span><span class="mi">901</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
|
|
<span class="k"> case</span><span class="p">(</span><span class="s1">'ncr'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">zs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">us</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">zs</span><span class="p">%</span><span class="n">is_positive_real</span><span class="p">()</span><span class="w"> </span><span class="p">.</span><span class="nb">and</span><span class="p">.</span><span class="w"> </span><span class="n">us</span><span class="p">%</span><span class="n">is_positive_real</span><span class="p">())</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> call </span><span class="n">invoke_binary</span><span class="p">(</span><span class="n">ncr_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else</span>
|
|
<span class="k"> goto</span><span class="w"> </span><span class="mi">901</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
|
|
<span class="k"> case</span><span class="p">(</span><span class="s1">'npr'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">zs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">us</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">zs</span><span class="p">%</span><span class="n">is_positive_real</span><span class="p">()</span><span class="w"> </span><span class="p">.</span><span class="nb">and</span><span class="p">.</span><span class="w"> </span><span class="n">us</span><span class="p">%</span><span class="n">is_positive_real</span><span class="p">())</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> call </span><span class="n">invoke_binary</span><span class="p">(</span><span class="n">npr_fr</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else</span>
|
|
<span class="k"> goto</span><span class="w"> </span><span class="mi">901</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> </span>
|
|
<span class="k"> case</span><span class="p">(</span><span class="s1">'m0+'</span><span class="p">,</span><span class="s1">'m1+'</span><span class="p">,</span><span class="s1">'m2+'</span><span class="p">,</span><span class="s1">'m3+'</span><span class="p">,</span><span class="s1">'m4+'</span><span class="p">,</span><span class="s1">'m5+'</span><span class="p">,</span><span class="s1">'m6+'</span><span class="p">,</span><span class="s1">'m7+'</span><span class="p">,</span><span class="s1">'m8+'</span><span class="p">,</span><span class="s1">'m9+'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">read</span><span class="p">(</span><span class="n">command</span><span class="p">(</span><span class="mi">2</span><span class="p">:</span><span class="mi">2</span><span class="p">),</span><span class="s1">'(i1)'</span><span class="p">,</span><span class="n">err</span><span class="o">=</span><span class="mi">901</span><span class="p">)</span><span class="w"> </span><span class="n">m</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">mem</span><span class="p">(</span><span class="n">m</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">mem</span><span class="p">(</span><span class="n">m</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'m0-'</span><span class="p">,</span><span class="s1">'m1-'</span><span class="p">,</span><span class="s1">'m2-'</span><span class="p">,</span><span class="s1">'m3-'</span><span class="p">,</span><span class="s1">'m4-'</span><span class="p">,</span><span class="s1">'m5-'</span><span class="p">,</span><span class="s1">'m6-'</span><span class="p">,</span><span class="s1">'m7-'</span><span class="p">,</span><span class="s1">'m8-'</span><span class="p">,</span><span class="s1">'m9-'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">read</span><span class="p">(</span><span class="n">command</span><span class="p">(</span><span class="mi">2</span><span class="p">:</span><span class="mi">2</span><span class="p">),</span><span class="s1">'(i1)'</span><span class="p">,</span><span class="n">err</span><span class="o">=</span><span class="mi">901</span><span class="p">)</span><span class="w"> </span><span class="n">m</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">mem</span><span class="p">(</span><span class="n">m</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">mem</span><span class="p">(</span><span class="n">m</span><span class="p">)</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'m0*'</span><span class="p">,</span><span class="s1">'m1*'</span><span class="p">,</span><span class="s1">'m2*'</span><span class="p">,</span><span class="s1">'m3*'</span><span class="p">,</span><span class="s1">'m4*'</span><span class="p">,</span><span class="s1">'m5*'</span><span class="p">,</span><span class="s1">'m6*'</span><span class="p">,</span><span class="s1">'m7*'</span><span class="p">,</span><span class="s1">'m8*'</span><span class="p">,</span><span class="s1">'m9*'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">read</span><span class="p">(</span><span class="n">command</span><span class="p">(</span><span class="mi">2</span><span class="p">:</span><span class="mi">2</span><span class="p">),</span><span class="s1">'(i1)'</span><span class="p">,</span><span class="n">err</span><span class="o">=</span><span class="mi">901</span><span class="p">)</span><span class="w"> </span><span class="n">m</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">mem</span><span class="p">(</span><span class="n">m</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">mem</span><span class="p">(</span><span class="n">m</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'m0/'</span><span class="p">,</span><span class="s1">'m1/'</span><span class="p">,</span><span class="s1">'m2/'</span><span class="p">,</span><span class="s1">'m3/'</span><span class="p">,</span><span class="s1">'m4/'</span><span class="p">,</span><span class="s1">'m5/'</span><span class="p">,</span><span class="s1">'m6/'</span><span class="p">,</span><span class="s1">'m7/'</span><span class="p">,</span><span class="s1">'m8/'</span><span class="p">,</span><span class="s1">'m9/'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">read</span><span class="p">(</span><span class="n">command</span><span class="p">(</span><span class="mi">2</span><span class="p">:</span><span class="mi">2</span><span class="p">),</span><span class="s1">'(i1)'</span><span class="p">,</span><span class="n">err</span><span class="o">=</span><span class="mi">901</span><span class="p">)</span><span class="w"> </span><span class="n">m</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">mem</span><span class="p">(</span><span class="n">m</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">mem</span><span class="p">(</span><span class="n">m</span><span class="p">)</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'st0'</span><span class="p">,</span><span class="s1">'st1'</span><span class="p">,</span><span class="s1">'st2'</span><span class="p">,</span><span class="s1">'st3'</span><span class="p">,</span><span class="s1">'st4'</span><span class="p">,</span><span class="s1">'st5'</span><span class="p">,</span><span class="s1">'st6'</span><span class="p">,</span><span class="s1">'st7'</span><span class="p">,</span><span class="s1">'st8'</span><span class="p">,</span><span class="s1">'st9'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">read</span><span class="p">(</span><span class="n">command</span><span class="p">(</span><span class="mi">3</span><span class="p">:</span><span class="mi">3</span><span class="p">),</span><span class="s1">'(i1)'</span><span class="p">,</span><span class="n">err</span><span class="o">=</span><span class="mi">901</span><span class="p">)</span><span class="w"> </span><span class="n">m</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">mem</span><span class="p">(</span><span class="n">m</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'sw0'</span><span class="p">,</span><span class="s1">'sw1'</span><span class="p">,</span><span class="s1">'sw2'</span><span class="p">,</span><span class="s1">'sw3'</span><span class="p">,</span><span class="s1">'sw4'</span><span class="p">,</span><span class="s1">'sw5'</span><span class="p">,</span><span class="s1">'sw6'</span><span class="p">,</span><span class="s1">'sw7'</span><span class="p">,</span><span class="s1">'sw8'</span><span class="p">,</span><span class="s1">'sw9'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">read</span><span class="p">(</span><span class="n">command</span><span class="p">(</span><span class="mi">3</span><span class="p">:</span><span class="mi">3</span><span class="p">),</span><span class="s1">'(i1)'</span><span class="p">,</span><span class="n">err</span><span class="o">=</span><span class="mi">901</span><span class="p">)</span><span class="w"> </span><span class="n">m</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">zs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stack</span><span class="p">%</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">set</span><span class="p">(</span><span class="n">mem</span><span class="p">(</span><span class="n">m</span><span class="p">))</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">mem</span><span class="p">(</span><span class="n">m</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">zs</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'rc0'</span><span class="p">,</span><span class="s1">'rc1'</span><span class="p">,</span><span class="s1">'rc2'</span><span class="p">,</span><span class="s1">'rc3'</span><span class="p">,</span><span class="s1">'rc4'</span><span class="p">,</span><span class="s1">'rc5'</span><span class="p">,</span><span class="s1">'rc6'</span><span class="p">,</span><span class="s1">'rc7'</span><span class="p">,</span><span class="s1">'rc8'</span><span class="p">,</span><span class="s1">'rc9'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">read</span><span class="p">(</span><span class="n">command</span><span class="p">(</span><span class="mi">3</span><span class="p">:</span><span class="mi">3</span><span class="p">),</span><span class="s1">'(i1)'</span><span class="p">,</span><span class="n">err</span><span class="o">=</span><span class="mi">901</span><span class="p">)</span><span class="w"> </span><span class="n">m</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">stack</span><span class="p">%</span><span class="n">push</span><span class="p">(</span><span class="n">mem</span><span class="p">(</span><span class="n">m</span><span class="p">))</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'cl0'</span><span class="p">,</span><span class="s1">'cl1'</span><span class="p">,</span><span class="s1">'cl2'</span><span class="p">,</span><span class="s1">'cl3'</span><span class="p">,</span><span class="s1">'cl4'</span><span class="p">,</span><span class="s1">'cl5'</span><span class="p">,</span><span class="s1">'cl6'</span><span class="p">,</span><span class="s1">'cl7'</span><span class="p">,</span><span class="s1">'cl8'</span><span class="p">,</span><span class="s1">'cl9'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">read</span><span class="p">(</span><span class="n">command</span><span class="p">(</span><span class="mi">3</span><span class="p">:</span><span class="mi">3</span><span class="p">),</span><span class="s1">'(i1)'</span><span class="p">,</span><span class="n">err</span><span class="o">=</span><span class="mi">901</span><span class="p">)</span><span class="w"> </span><span class="n">m</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">mem</span><span class="p">(</span><span class="n">m</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">rpn_t</span><span class="p">()</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'msh'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">write</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span><span class="s1">'(i3,a,dt)'</span><span class="p">)</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="p">,</span><span class="s1">': '</span><span class="p">,</span><span class="n">mem</span><span class="p">(</span><span class="n">i</span><span class="p">),</span><span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span><span class="n">size</span><span class="p">(</span><span class="n">mem</span><span class="p">)</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'fix0'</span><span class="p">,</span><span class="s1">'fix1'</span><span class="p">,</span><span class="s1">'fix2'</span><span class="p">,</span><span class="s1">'fix3'</span><span class="p">,</span><span class="s1">'fix4'</span><span class="p">,</span><span class="s1">'fix5'</span><span class="p">,</span><span class="s1">'fix6'</span><span class="p">,</span><span class="s1">'fix7'</span><span class="p">,</span><span class="s1">'fix8'</span><span class="p">,</span><span class="s1">'fix9'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">read</span><span class="p">(</span><span class="n">command</span><span class="p">(</span><span class="mi">4</span><span class="p">:</span><span class="mi">4</span><span class="p">),</span><span class="s1">'(i1)'</span><span class="p">)</span><span class="w"> </span><span class="n">m</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">set_places</span><span class="p">(</span><span class="n">m</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span>
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'DEG'</span><span class="p">,</span><span class="s1">'deg'</span><span class="p">,</span><span class="s1">'DEGREES'</span><span class="p">,</span><span class="s1">'degrees'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">toggle_degrees_mode</span><span class="p">(.</span><span class="n">true</span><span class="p">.)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'RAD'</span><span class="p">,</span><span class="s1">'rad'</span><span class="p">,</span><span class="s1">'RADIANS'</span><span class="p">,</span><span class="s1">'radians'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">toggle_degrees_mode</span><span class="p">(.</span><span class="n">false</span><span class="p">.)</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'mC'</span><span class="p">,</span><span class="s1">'COMPLEX'</span><span class="p">,</span><span class="s1">'complex'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">complex_mode</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">true</span><span class="p">.</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'mR'</span><span class="p">,</span><span class="s1">'REAL'</span><span class="p">,</span><span class="s1">'real'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">complex_mode</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">false</span><span class="p">.</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'mV'</span><span class="p">,</span><span class="s1">'VERBOSE'</span><span class="p">,</span><span class="s1">'verbose'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">veMode</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">true</span><span class="p">.</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'mT'</span><span class="p">,</span><span class="s1">'TERSE'</span><span class="p">,</span><span class="s1">'terse'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">veMode</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">.</span><span class="n">false</span><span class="p">.</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'?'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">write</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span><span class="n">advance</span><span class="o">=</span><span class="s1">'no'</span><span class="p">,</span><span class="n">fmt</span><span class="o">=</span><span class="s1">'(a)'</span><span class="p">)</span><span class="w"> </span><span class="s1">'Status: '</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">write</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span><span class="n">advance</span><span class="o">=</span><span class="s1">'no'</span><span class="p">,</span><span class="n">fmt</span><span class="o">=</span><span class="s1">'(2a)'</span><span class="p">)</span><span class="w"> </span><span class="nb">merge</span><span class="p">(</span><span class="s1">'degrees'</span><span class="p">,</span><span class="s1">'radians'</span><span class="p">,</span><span class="n">degrees_mode</span><span class="p">),</span><span class="s1">' ; '</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">write</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span><span class="n">advance</span><span class="o">=</span><span class="s1">'no'</span><span class="p">,</span><span class="n">fmt</span><span class="o">=</span><span class="s1">'(a,i0)'</span><span class="p">)</span><span class="w"> </span><span class="s1">'dp = '</span><span class="p">,</span><span class="n">get_places</span><span class="p">()</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">complex_mode</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> write</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span><span class="n">advance</span><span class="o">=</span><span class="s1">'no'</span><span class="p">,</span><span class="n">fmt</span><span class="o">=</span><span class="s1">'(a)'</span><span class="p">)</span><span class="w"> </span><span class="s1">' ; mode = complex'</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else</span>
|
|
<span class="k"> write</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span><span class="n">advance</span><span class="o">=</span><span class="s1">'no'</span><span class="p">,</span><span class="n">fmt</span><span class="o">=</span><span class="s1">'(a)'</span><span class="p">)</span><span class="w"> </span><span class="s1">' ; mode = real'</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> write</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span><span class="n">advance</span><span class="o">=</span><span class="s1">'no'</span><span class="p">,</span><span class="n">fmt</span><span class="o">=</span><span class="s1">'(a,i0)'</span><span class="p">)</span><span class="w"> </span><span class="s1">' ; stack size = '</span><span class="p">,</span><span class="n">stack</span><span class="p">%</span><span class="n">get_size</span><span class="p">()</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">write</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span><span class="s1">'(a/)'</span><span class="p">)</span><span class="w"> </span><span class="s1">''</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case</span><span class="p">(</span><span class="s1">'help'</span><span class="p">,</span><span class="s1">'h'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">call </span><span class="n">help</span><span class="w"></span>
|
|
|
|
<span class="w"> </span><span class="k">case </span><span class="n">default</span><span class="w"></span>
|
|
<span class="w"> </span><span class="c">! Process constants first</span>
|
|
<span class="w"> </span><span class="k">block</span>
|
|
<span class="k"> </span><span class="kt">integer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">lc</span><span class="p">,</span><span class="w"> </span><span class="n">is_integer</span><span class="p">,</span><span class="n">split_idx</span><span class="p">,</span><span class="n">end_idx</span><span class="w"></span>
|
|
<span class="w"> </span><span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="p">:),</span><span class="w"> </span><span class="k">allocatable</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">re_comp</span><span class="p">,</span><span class="w"> </span><span class="n">im_comp</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">lc</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">len_trim</span><span class="p">(</span><span class="n">command</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">is_integer</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="nb">index</span><span class="p">(</span><span class="n">command</span><span class="p">,</span><span class="s1">'.'</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">0</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">complex_mode</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="n">command</span><span class="p">(</span><span class="mi">1</span><span class="p">:</span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s1">'('</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">split_idx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">index</span><span class="p">(</span><span class="n">command</span><span class="p">,</span><span class="s1">','</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">end_idx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">index</span><span class="p">(</span><span class="n">command</span><span class="p">,</span><span class="s1">')'</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">re_comp</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">command</span><span class="p">(</span><span class="mi">2</span><span class="p">:</span><span class="n">split_idx</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">im_comp</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">command</span><span class="p">(</span><span class="n">split_idx</span><span class="o">+</span><span class="mi">1</span><span class="p">:</span><span class="n">end_idx</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">constants</span><span class="p">%</span><span class="k">contains</span><span class="p">(</span><span class="n">re_comp</span><span class="p">))</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">z</span><span class="p">%</span><span class="n">re</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">constants</span><span class="p">%</span><span class="n">get_value</span><span class="p">(</span><span class="n">re_comp</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else</span>
|
|
<span class="k"> read</span><span class="p">(</span><span class="n">re_comp</span><span class="p">,</span><span class="o">*</span><span class="p">,</span><span class="n">err</span><span class="o">=</span><span class="mi">901</span><span class="p">,</span><span class="k">end</span><span class="o">=</span><span class="mi">901</span><span class="p">)</span><span class="w"> </span><span class="n">z</span><span class="p">%</span><span class="n">re</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="n">constants</span><span class="p">%</span><span class="k">contains</span><span class="p">(</span><span class="n">im_comp</span><span class="p">))</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">z</span><span class="p">%</span><span class="n">im</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">constants</span><span class="p">%</span><span class="n">get_value</span><span class="p">(</span><span class="n">im_comp</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else</span>
|
|
<span class="k"> read</span><span class="p">(</span><span class="n">im_comp</span><span class="p">,</span><span class="o">*</span><span class="p">,</span><span class="n">err</span><span class="o">=</span><span class="mi">901</span><span class="p">,</span><span class="k">end</span><span class="o">=</span><span class="mi">901</span><span class="p">)</span><span class="w"> </span><span class="n">z</span><span class="p">%</span><span class="n">im</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="n">command</span><span class="p">(</span><span class="n">lc</span><span class="p">:</span><span class="n">lc</span><span class="p">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s1">'p'</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> call </span><span class="n">stack</span><span class="p">%</span><span class="n">push</span><span class="p">(</span><span class="n">z</span><span class="p">,.</span><span class="n">false</span><span class="p">.)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else</span>
|
|
<span class="k"> call </span><span class="n">stack</span><span class="p">%</span><span class="n">push</span><span class="p">(</span><span class="n">z</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> else</span>
|
|
<span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="n">constants</span><span class="p">%</span><span class="k">contains</span><span class="p">(</span><span class="n">command</span><span class="p">))</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">constants</span><span class="p">%</span><span class="n">get_value</span><span class="p">(</span><span class="n">command</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else</span>
|
|
<span class="k"> read</span><span class="p">(</span><span class="n">command</span><span class="p">,</span><span class="o">*</span><span class="p">,</span><span class="n">err</span><span class="o">=</span><span class="mi">901</span><span class="p">,</span><span class="k">end</span><span class="o">=</span><span class="mi">901</span><span class="p">)</span><span class="w"> </span><span class="n">x</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> call </span><span class="n">stack</span><span class="p">%</span><span class="n">push</span><span class="p">(</span><span class="nb">cmplx</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="mf">0.0d0</span><span class="p">,</span><span class="mi">8</span><span class="p">))</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> </span>
|
|
<span class="k"> else</span>
|
|
<span class="k"> if</span><span class="w"> </span><span class="p">(</span><span class="n">constants</span><span class="p">%</span><span class="k">contains</span><span class="p">(</span><span class="n">command</span><span class="p">))</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">constants</span><span class="p">%</span><span class="n">get_value</span><span class="p">(</span><span class="n">command</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else if</span><span class="w"> </span><span class="p">(</span><span class="n">stats</span><span class="p">%</span><span class="k">contains</span><span class="p">(</span><span class="n">command</span><span class="p">))</span><span class="w"> </span><span class="k">then</span>
|
|
<span class="k"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stats</span><span class="p">%</span><span class="n">get_value</span><span class="p">(</span><span class="n">command</span><span class="p">)</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">else</span>
|
|
<span class="k"> read</span><span class="p">(</span><span class="n">command</span><span class="p">,</span><span class="o">*</span><span class="p">,</span><span class="n">err</span><span class="o">=</span><span class="mi">901</span><span class="p">,</span><span class="k">end</span><span class="o">=</span><span class="mi">901</span><span class="p">)</span><span class="w"> </span><span class="n">x</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> call </span><span class="n">stack</span><span class="p">%</span><span class="n">push</span><span class="p">(</span><span class="nb">cmplx</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="mf">0.0d0</span><span class="p">,</span><span class="mi">8</span><span class="p">))</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">end if</span>
|
|
<span class="k"> end block</span>
|
|
<span class="k"> end select</span>
|
|
<span class="k"> return</span>
|
|
|
|
<span class="mi">901</span><span class="w"> </span><span class="k">continue</span>
|
|
<span class="k"> write</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span><span class="s1">'(a)'</span><span class="p">)</span><span class="w"> </span><span class="n">command</span><span class="o">//</span><span class="s1">' ???'</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">return</span>
|
|
<span class="k"> </span>
|
|
<span class="k"> end subroutine </span><span class="n">apply_command</span><span class="w"></span>
|
|
</pre></div>
|
|
|
|
</section>
|
|
<br>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<hr>
|
|
</div> <!-- /container -->
|
|
<footer>
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-xs-6 col-md-6"><p>hp was developed by sgeard<br>© 2023
|
|
</p>
|
|
</div>
|
|
<div class="col-xs-6 col-md-6">
|
|
<p class="text-right">
|
|
Documentation generated by
|
|
<a href="https://github.com/Fortran-FOSS-Programmers/ford">FORD</a>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<br>
|
|
</div> <!-- /container -->
|
|
</footer>
|
|
|
|
<!-- Bootstrap core JavaScript
|
|
================================================== -->
|
|
<!-- Placed at the end of the document so the pages load faster -->
|
|
<!--
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
|
-->
|
|
<script src="../js/bootstrap.min.js"></script>
|
|
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
|
<script src="../js/ie10-viewport-bug-workaround.js"></script>
|
|
|
|
<!-- MathJax JavaScript
|
|
================================================== -->
|
|
<!-- Placed at the end of the document so the pages load faster -->
|
|
<script type="text/x-mathjax-config">
|
|
MathJax.Hub.Config({
|
|
TeX: { extensions: ['AMSmath.js','AMSsymbols.js','noErrors.js','noUndefined.js'], equationNumbers: { autoNumber: 'AMS' } },
|
|
jax: ['input/TeX','input/MathML','output/HTML-CSS'],
|
|
extensions: ['tex2jax.js','mml2jax.js','MathMenu.js','MathZoom.js']
|
|
});
|
|
</script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
|
|
|
<script src="../tipuesearch/tipuesearch_content.js"></script>
|
|
<script src="../tipuesearch/tipuesearch_set.js"></script>
|
|
<script src="../tipuesearch/tipuesearch.js"></script>
|
|
|
|
</body>
|
|
</html> |