std.office.calc โ Zero-GC Spreadsheet Engine & AI Tabular Assistant
A high-performance columnar spreadsheet engine built natively in Nyx with natural language tabular queries, automated formula synthesis, Z-score statistical anomaly detection, and linear trend forecasting.
๐ฌ Natural Language Querying
Query tabular datasets directly with English questions like "What is the total revenue in Q3?" or "Compute average expenses".
โจ Automated Formula Synthesizer
Generates complex multi-range formulas (e.g. =XLOOKUP(), compound growth, variance) automatically from English descriptions.
๐จ Z-Score Outlier Detection
Identifies data anomalies where |x - ฮผ| > 2.0ฯ (Z-score > 2.0) with zero heap allocation overhead.
๐ Linear Trend Forecasting
Computes ordinary least squares regression (slope, intercept, Rยฒ) to project future time-series values deterministically.
1. Quick Start Example
import std.office.calc;
import std.io;
fn main() {
region arena {
// Initialize a 100-row x 5-column financial worksheet
let mut sheet = NyxCalcSheet.new("Q3_Financials", 100, 5);
// Populate monthly revenue data
sheet.set_cell_number(1, 1, 45000.0); // Month 1: $45k
sheet.set_cell_number(2, 1, 52000.0); // Month 2: $52k
sheet.set_cell_number(3, 1, 61000.0); // Month 3: $61k
sheet.set_cell_number(4, 1, 185000.0); // Month 4: $185k (Anomaly!)
sheet.set_cell_number(5, 1, 64000.0); // Month 5: $64k
// 1. Natural Language Query
let response = sheet.query_natural_language("What is the total sum?");
io.println("AI Assistant: ", response);
// 2. Statistical Outlier Detection (Z-Score > 2.0)
let anomalies = sheet.detect_outliers(1);
io.println("๐จ Anomalies detected: ", anomalies.len());
// 3. Linear Trend Forecasting for Next 3 Periods
let forecast = sheet.forecast_linear(1, 3);
io.println("๐ Projected Month 6 Revenue: $", forecast.predictions[0]);
}
}
2. Automated Formula Synthesizer
Convert English requirements into executable Excel-compatible formula expressions:
let formula1 = sheet.synthesize_formula("lookup user email in customer catalog");
// Returns: =XLOOKUP(A2, Catalog!A:A, Catalog!C:C, "Not Found")
let formula2 = sheet.synthesize_formula("calculate percentage revenue growth");
// Returns: =(C2 - B2) / B2 * 100
let formula3 = sheet.synthesize_formula("compound interest future value");
// Returns: =PV * (1 + R)^N
3. API Reference
| Method / Function | Parameters | Return Type | Description |
|---|---|---|---|
NyxCalcSheet.new(name, rows, cols) |
String, Int, Int |
NyxCalcSheet |
Initializes a new zero-GC tabular sheet. |
set_cell_number(row, col, val) |
Int, Int, Float |
void |
Sets cell coordinate with a 64-bit float value. |
query_natural_language(query) |
String |
String |
Parses English query and executes aggregations. |
synthesize_formula(task_desc) |
String |
String |
Generates Excel-compatible formula string. |
detect_outliers(col) |
Int |
Vec[Cell] |
Detects data points exceeding Z-score > 2.0. |
forecast_linear(col, future_periods) |
Int, Int |
ForecastResult |
Computes least squares regression & future projections. |