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)[源代码]¶
基类:
objectA word in fixed-point arithmetic expressions; overloaded operators delegate to the owning builder.
- 变量:
algebra (oracq.applications.roe.ArithmeticBuilder) -- The
ArithmeticBuilderthat produced this word and emits the actual arithmetic nodes.ref (oracq.infrastructure.ir.Ref) -- The register reference carrying the value.
- algebra¶
- ref¶
- class oracq.applications.roe.ArithmeticBuilder(builder, fmt)[源代码]¶
基类:
objectHost-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
Worduniformly.A
Wordis returned as-is; a register reference with apartsattribute 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.
- 返回类型:
- 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
flagsand aggregated byfinish.- 参数:
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
selectoperation; unused by other operations.
- 返回:
The word carrying the operation result.
- 返回类型:
- choose(bit, yes, no)[源代码]¶
Select between two words by a single control bit: value 1 picks
yesand 0 picksno.- 参数:
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.
- 返回类型:
- 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.
- 返回类型:
- 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 viaAdjoint, 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.
- 返回类型:
- 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_facewith fixed-point arithmetic.- 返回类型: