Review before applying
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
PivotQuartz is a Windows AI coding client for reasoning about exact linear algebra. Discuss pivot selection in the context of your files, then review the proposed fraction operations and singular-system behavior.
from fractions import Fraction
def solve_linear(matrix, rhs):
matrix, rhs = [tuple(row) for row in matrix], tuple(rhs)
n = len(matrix)
if not 1 <= n <= 8 or len(rhs) != n or any(len(row) != n for row in matrix):
raise ValueError("system.shape")
if any(type(v) is not int or abs(v) > 1000000 for row in matrix for v in row) or any(type(v) is not int or abs(v) > 1000000 for v in rhs):
raise ValueError("coefficient.range")
a = [[Fraction(v) for v in row] + [Fraction(rhs[i])] for i, row in enumerate(matrix)]
for col in range(n):
pivot = next((r for r in range(col, n) if a[r][col]), None)
if pivot is None:
raise ValueError("system.singular")
a[col], a[pivot] = a[pivot], a[col]
scale = a[col][col]
a[col] = [v / scale for v in a[col]]
for r in range(n):
if r != col:
factor = a[r][col]
a[r] = [x - factor * y for x, y in zip(a[r], a[col])]
return [row[-1] for row in a]Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
Base URL, credentials and a reachable server.
Test a required row swap and a fractional solution, rejecting singular systems or mismatched dimensions while preserving the inputs.
from fractions import Fraction
def solve_linear(matrix, rhs):
matrix, rhs = [tuple(row) for row in matrix], tuple(rhs)
n = len(matrix)
if not 1 <= n <= 8 or len(rhs) != n or any(len(row) != n for row in matrix):
raise ValueError("system.shape")
if any(type(v) is not int or abs(v) > 1000000 for row in matrix for v in row) or any(type(v) is not int or abs(v) > 1000000 for v in rhs):
raise ValueError("coefficient.range")
a = [[Fraction(v) for v in row] + [Fraction(rhs[i])] for i, row in enumerate(matrix)]
for col in range(n):
pivot = next((r for r in range(col, n) if a[r][col]), None)
if pivot is None:
raise ValueError("system.singular")
a[col], a[pivot] = a[pivot], a[col]
scale = a[col][col]
a[col] = [v / scale for v in a[col]]
for r in range(n):
if r != col:
factor = a[r][col]
a[r] = [x - factor * y for x, y in zip(a[r], a[col])]
return [row[-1] for row in a]PivotQuartz is a Windows coding workspace for developing numerical application code with explicit acceptance criteria. Open the project folder and identify the function, its input representation and the consumer of its result. The connected model can discuss a change in that context, while you inspect whether the proposal preserves the caller’s assumptions.
A review request using linear.py might compare an exact fractional result with what the application expects to display or serialize. Supply a small system with a known solution and a singular case that must be rejected. Ask how a proposed refactor handles both paths before accepting changes to arithmetic or result types.
This workflow makes correctness and integration part of the same discussion. Run independent result checks in your development environment, then examine errors and output formatting through the caller. Converting fractions to floating-point values may be a deliberate application choice, but it deserves a stated boundary rather than appearing incidentally inside a cleanup.
Choose an uncensored AI model where available through a supported OpenAI-compatible or Anthropic endpoint, providing credentials when required. Provider restrictions remain in force, and the model and server set tool support and context capacity. PivotQuartz supplies the workspace for reviewing source; your project’s expected results provide the evidence for accepting an edit.
Only if your application explicitly requires an approximation with a defined meaning. The example rejects singular systems. Inspect how the caller handles that failure and keep a change to approximation behavior separate from a refactor intended to preserve exact results.
Substitute it into the original equations using an appropriate independent calculation and compare with the supplied right-hand side. Include a case requiring a row exchange. Verify the output representation too, since a correct value can still violate the caller’s expected type.
Usually the layer responsible for presentation should make that decision explicitly. Inspect the current project structure and define the format required by its consumer. Avoid introducing rounding in an internal helper unless that is part of the agreed numerical contract.
Provide the routine, the code constructing its inputs and the caller’s error handling. Include mismatched dimensions as a fixture. A test of the inner arithmetic alone cannot establish that malformed application data receives the response your interface expects.
PivotQuartz · Updated 2026-10-25