Roe 矩阵元生成

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)[源代码]

基类:object

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

变量:
algebra
ref
sqrt()[源代码]

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

返回:

The new arithmetic word carrying the square root result.

返回类型:

Word

abs()[源代码]

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

返回:

The new arithmetic word carrying the absolute value result.

返回类型:

Word

class oracq.applications.roe.ArithmeticBuilder(builder, fmt)[源代码]

基类: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)[源代码]

Allocate a new private register for intermediate values or constants.

参数:

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

返回:

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

word(value)[源代码]

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.

参数:

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

返回:

The arithmetic word equivalent to the input.

返回类型:

Word

calc(kind, *args, select=None)[源代码]

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.

参数:
  • 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.

返回:

The word carrying the operation result.

返回类型:

Word

choose(bit, yes, no)[源代码]

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

参数:
  • 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.

返回:

The arithmetic word carrying the selected value.

返回类型:

Word

choose3(index, values)[源代码]

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

参数:
  • index -- The two-bit control sequence, least significant bit first.

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

返回:

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

返回类型:

Word

finish(outputs, status)[源代码]

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.

参数:
  • outputs -- Pairs of target register and result word.

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

返回:

The complete generated operation.

返回类型:

Operation

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

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

参数:
  • 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.

返回:

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

返回类型:

Operation