Skip to content

Add block arithmetic operations#78

Open
tran-go wants to merge 2 commits into
devfrom
56-block-arthmetics
Open

Add block arithmetic operations#78
tran-go wants to merge 2 commits into
devfrom
56-block-arthmetics

Conversation

@tran-go

@tran-go tran-go commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Purpose

Issue: #56

This PR adds block matrix arithmetic support on top of the block tensor classes and constructors.

It enables large matrices and vectors to be split into encoded blocks when the logical input requires more slots than one ciphertext can provide.

Scope

  1. This PR adds block support for:
  • + / add;
  • - / subtract;
  • * / elementwise multiply;
  • matrix-vector multiplication, matrix @ vector;
  • matrix-matrix multiplication, matrix @ matrix;
  • negation;
  • transpose;
  • cumulative sum;
  • sum.
  • component-wise function execution
  1. Rename cumulative_sum to cumsum for NumPy API compatibility.
  2. Rename pow to power for NumPy API compatibility.
  3. Move auxiliary arithmetic helpers to arithmetic_utils.py.
  4. Move block arithmetic logic and helpers to block_arithmetic.py and block_arithmetic_utils.py.

Out of scope

This PR also does not add full NumPy slicing, broadcasting, or general block reshaping support.

Validation

Added and ran simple block arithmetic tests covering:

  • block vector arithmetic;
  • block matrix arithmetic;
  • block matrix-vector multiplication;
  • oversized matrix/vector inputs that require block packing.

@tran-go tran-go linked an issue Jul 16, 2026 that may be closed by this pull request
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add matrix block arithmetic

1 participant