Language reference

Matrix editing and management

How to inspect, change, slice, and persist matrices with the current Sun interpreter.

01

Working with matrices

Sun has dense, two-dimensional real, logical and complex arrays. Use assignments to create and replace variables; the interpreter keeps values in the active session.

Sun Studio's Variable Editor edits existing real, logical and complex cells in pages of 30 rows by 20 columns. Open an array from Workspace, edit cells and save while execution is idle. Scalar and text values have a separate editor.

02

Edit individual elements

Indices begin at 1. A(row, column) edits one existing element; A(index) uses column-major linear order. Out-of-bounds writes do not automatically grow the matrix.

Sun
A = [10, 20, 30; 40, 50, 60];
A(2, 3) = 65;
disp(A);
03

Assign slices

A scalar or 1x1 matrix fills the selected region. Two-dimensional matrix assignments require matching rows and columns; linear slice writes require matching element count. The right side is evaluated before the destination is modified, and validation prevents partial writes on shape/index errors.

Slices can use :, integer ranges, reverse steps, and end. Slice reads return independent matrix values rather than views.

Sun
A = [1, 2, 3; 4, 5, 6; 7, 8, 9];
A(:, end) = 0;
A(1:2, 1:2) = [10, 20; 30, 40];
A(1:2:end) = 7;
disp(A);
04

Inspect shape and contents

size returns a two-element row matrix [rows, columns]; numel counts elements, and isempty tests whether a matrix is empty. Empty selections preserve zero-sized axes.

Sun
A = zeros(3, 2);
disp(size(A));
disp(numel(A));
disp(isempty(A));
disp(A(:));
05

Import and export

readmatrix and writematrix operate on headerless numeric UTF-8 CSV files and are available through the interpreter with filesystem host access. Writes use atomic replacement. This is file persistence, not session-state restoration.

Sun
data = readmatrix("input.csv");
writematrix(data, "output.csv");
06

Save and copy cells

The editor supports rectangular selection and TSV copy/paste, up to 4096 pasted cells within the existing dimensions. Real cells accept NaN and infinities; logical cells accept true/false; complex cells accept values such as 1+2i.

Each cell update checks the Workspace revision to prevent stale writes. A multi-cell save sends updates one at a time: if a later update fails, earlier successful edits remain and the page is refreshed. It is not an atomic batch or an edit of the source program.

07

Current limits

Support boundary

There is no resize control, implicit growth, deletion by assigning [] or runtime Workspace restoration after restart. Logical indexing is supported by the interpreter. The LLVM backend does not compile slices or CSV effects.

Sun is proprietary software under experimental development. Documentation scope: Sun 0.6 development snapshot.