Roe matrix-element generation

oracq.applications.roe

Reversible arithmetic generation of one-dimensional Euler frozen-Roe matrix elements; physical and fixed-point correctness pending verification.

class oracq.applications.roe.Word(algebra, ref)[source]

Bases: object

A word in fixed-point arithmetic expressions; overloaded operators delegate to the owning builder.

Variables:
algebra
ref
sqrt()[source]

Emit an arithmetic node taking the square root of this word and return the word carrying the result.

Returns:

The new arithmetic word carrying the square root result.

Return type:

Word

abs()[source]

Emit an arithmetic node taking the absolute value of this word and return the word carrying the result.

Returns:

The new arithmetic word carrying the absolute value result.

Return type:

Word

class oracq.applications.roe.ArithmeticBuilder(builder, fmt)[source]

Bases: object

Host-side expression builder; on finish only module calls or gates and private registers remain.

b
fmt
count
constants
flags
start
local(width=None)[source]

Allocate a new private register for intermediate values or constants.

Parameters:

width – Bit width; defaults to the word width of the current fixed-point format.

Returns:

The newly allocated register reference, named v_ plus an incrementing counter.

word(value)[source]

Wrap various inputs into a Word uniformly.

A Word is returned as-is; a register reference with a parts attribute is wrapped directly; numeric values are encoded in the current fixed-point format, and constants with the same encoding are materialized once and share one register.

Parameters:

value – A Word, a register reference, or a numeric value encodable in the fixed-point format.

Returns:

The arithmetic word equivalent to the input.

Return type:

Word

calc(kind, *args, select=None)[source]

Emit one fixed-point arithmetic node and return its output word.

When the same register is reused as an operand, it is first copied with XOR into a fresh register and restored after the call, supporting cases such as squaring where a value participates in its own operation; the node status register is recorded in flags and aggregated by finish.

Parameters:
  • kind – Operation type name, e.g. add, mul, sqrt.

  • *args – Operands; each may be a Word, a register, or a numeric value.

  • select – The control bit for the select operation; unused by other operations.

Returns:

The word carrying the operation result.

Return type:

Word

choose(bit, yes, no)[source]

Select between two words by a single control bit: value 1 picks yes and 0 picks no.

Parameters:
  • bit – A one-bit control register view.

  • yes – The word, register or numeric value selected when the control bit is 1.

  • no – The word, register or numeric value selected when the control bit is 0.

Returns:

The arithmetic word carrying the selected value.

Return type:

Word

choose3(index, values)[source]

Select among three candidate words with a two-bit index.

Parameters:
  • index – The two-bit control sequence, least significant bit first.

  • values – The three candidate words, corresponding to indices 0..2 in order.

Returns:

The selected word; the result is zero when the index is 3.

Return type:

Word

finish(outputs, status)[source]

Finalize and return the resulting operation.

Each output word is XORed into its target register; the status bits of the arithmetic nodes are bitwise-ORed into status; the forward instructions emitted during construction are replayed in reverse via Adjoint, erasing all intermediate values.

Parameters:
  • outputs – Pairs of target register and result word.

  • status – The two-bit register receiving the aggregated status.

Returns:

The complete generated operation.

Return type:

Operation

oracq.applications.roe.roe_face(*, fmt=None, gamma=1.4, entropy_delta=0.125)[source]

Automatic compilation of a plain Python Roe function, keeping the existing six-field plus row and column input ABI.

Parameters:
  • fmt – The fixed-point format for field values and fluxes; defaults to FixedFormat(10, 5).

  • gamma – Ratio of specific heats.

  • entropy_delta – Harten entropy fix threshold.

Returns:

The reversible face-flux computation module auto-compiled from frozen_roe_face with fixed-point arithmetic.

Return type:

Operation