Skip to content

Small changes to tiny expression for improved usability#2463

Merged
willend merged 3 commits into
mainfrom
tinyexpr_additions
May 13, 2026
Merged

Small changes to tiny expression for improved usability#2463
willend merged 3 commits into
mainfrom
tinyexpr_additions

Conversation

@Lomholy
Copy link
Copy Markdown
Collaborator

@Lomholy Lomholy commented May 12, 2026

Free-form text area

This PR adds a heavyside and gauss function to tinyexpr.c and force tinyexpr to evaluate exponentials from right to left.

This PR then implements a test of the two new functions in the relevant test instrument

Finally documentation of these small additions have been added documentation to Inhomogenous_incoherent_process.comp

This adds the features requested by me in #2461.


Development OS / boundary conditions

MacOS Tahoe 26.4


PR Checklist for contributing to McStas/McXtrace

For a coherent and useful contribution to McStas/McXtrace, please fill in relevant parts of the checklist:

  • My contribution includes patches to an existing component file

    • I have used the mcdoc utility and rendered a reasonable documentation page for the component (please attach as screenshot in comments!)
  • My contribution includes patches to an existing instrument file

    • I have used the mcdoc utility and rendered a reasonable documentation page for the instrument (please attach as screenshot in comments!)
    • I have used the mctest utility to test the instrument (please attach mcviewtest report as screenshot in comments)
    • I have used the mcrun --c-lint "linter" and followed advice to remove most / all warnings that are raised
  • My work touches / adds to the runtime lib code (.c,.h etc in multiple locations

    • I am have added reasoning and documentation for the change below

@Lomholy
Copy link
Copy Markdown
Collaborator Author

Lomholy commented May 12, 2026

Mcviewtest of the inhomogenous process component
image

Mcdoc of the inhomogenous_process component. For some reason the latex seems to not be loading correctly. Did I mess something up, or have you seen this before, @willend ?:
image

image image

Mcdoc of test
image

@Lomholy
Copy link
Copy Markdown
Collaborator Author

Lomholy commented May 12, 2026

Running the --c-linter gives warnings on the phonon_simple process:
image

But otherwise no warnings or errors from the linter.

@willend
Copy link
Copy Markdown
Contributor

willend commented May 12, 2026

@Lomholy OK.

I think we should soonish have a discussion about “tinyexpr” - which I guess is by now already “something else based on tinyexpr” since there are local edits wrt. upstream https://codeplea.com/tinyexpr.

Since upstream is zlib license != GPL3 normal practice is in fact not to “just dump” a modified file in McStas.

A more correct approach would be to define/build a “derived package” from a fork of the original project ( could e.g. be the one I have already put in https://github.com/mccode-dev/tinyexpr ) and make a stand-alone package from that to be installed as a dependency.

( Having had another look at what is written upstream he sort of does hint at “just including in your own project” - but I think we could / should do something a little more streamlined that more easily allows updates from upstream developments… :-) )

@willend
Copy link
Copy Markdown
Contributor

willend commented May 12, 2026

@Lomholy I can look at the \TeX later - or you can check that you are wrapping in the correct html tags as shown in https://github.com/mccode-dev/McCode/wiki/mcdoc-component-header under point 8?

@willend
Copy link
Copy Markdown
Contributor

willend commented May 13, 2026

@Lomholy wrt. the TeX, something seemingly broke in mcdoc itself. Should not prevent merging here.

@willend
Copy link
Copy Markdown
Contributor

willend commented May 13, 2026

TeX fixed, problem with webserver certificate

@willend
Copy link
Copy Markdown
Contributor

willend commented May 13, 2026

Screenshot 2026-05-13 at 09 11 24 Corrected TeX in mcdoc.

I will write a discussion item to exchange on a less hand-held solution for tinyexpr.

Merging.

@willend willend merged commit a460eac into main May 13, 2026
28 checks passed
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