Skip to content

Conversation

@cbmarini
Copy link
Collaborator

@cbmarini cbmarini commented Oct 7, 2025

This PR introduces a new Chop statement that removes floating point numbers below a specified threshold.

  • Its behaviour is similar to Mathematica's chop statement.
  • The threshold can either be specified as a float or rational.
  • It only chops floats, so rationals are untouched.

Example usage:

#StartFloat 15d
Symbol a,b,c;
CFunction f,g;
Local F = 1.0e-10*a+4.7*b+.2e-10*c+f(2,0.000001)+g(2.,1);
Chop 1.0e-10;
Argument f;
	Chop 1/10000;
EndArgument;
Argument g;
	Chop 7;
EndArgument;
Print;
.end

results in

F =
      4.7e+00*b + 1.0e-10*a + f(2,0) + g(0,1);

@coveralls
Copy link

coveralls commented Oct 7, 2025

Coverage Status

coverage: 57.069% (+0.05%) from 57.024%
when pulling fe4a9cc on cbmarini:chop
into 01a66ec on form-dev:master.

… a given threshold.

- The threshold can be specified as a float, integer, rational or power.
- added a test and  documentation for the chop statement.

fix: switched the commands cleartable and clearflag in comm2commands such that they are in alphabetical order.
@cbmarini cbmarini merged commit 42d314c into form-dev:master Oct 28, 2025
84 checks passed
@cbmarini cbmarini deleted the chop branch October 28, 2025 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants