largest-eigenval

Optimize largest eigenvalue computation for small dense matrices using Cython and LAPACK.

134|21|Updated Nov 12, 2025
One-click install
npx skills add https://github.com/letta-ai/skills --skill largest-eigenval
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: largest-eigenval
Source: https://github.com/letta-ai/skills/tree/main/ai/benchmarks/letta/terminal-bench-2/trajectory-feedback/largest-eigenval
Command: npx skills add https://github.com/letta-ai/skills --skill largest-eigenval

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides optimizing numerical linear algebra workloads, focusing on computing the largest eigenvalue for small dense matrices faster than conventional library approaches.

Core Features & Use Cases

  • Profile-driven decisions to avoid Python overhead for small matrices
  • Approaches including Cython+LAPACK layouts and alternative algorithms
  • Validation and correctness checks against reference implementations

Quick Start

Implement a tiny, fast eigenvalue path using Cython+LAPACK and compare with numpy.linalg.eig on a small matrix.

Frequently Asked Questions about largest-eigenval

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make eigenvalue computation faster for small matrices?

Small matrix eigenvalue problems benefit from minimizing Python overhead by using Cython extensions with direct LAPACK calls instead of standard numpy.linalg.eig. This approach reduces wrapper overhead and achieves significant speedup on matrices roughly 2x2 to 100x100 where performance-critical numerical tasks dominate.

When should I use Cython and LAPACK for eigenvalue solving instead of numpy?

Use Cython with LAPACK when solving eigenvalues on small dense matrices where Python function-call overhead is the bottleneck. For matrices under ~100x100 in performance-critical loops, Cython typed memoryviews and direct LAPACK bindings outperform numpy.linalg.eig, especially with check_finite=False optimizations.

What's the best way to profile and optimize eigenvalue performance for my use case?

Profile your reference eigenvalue implementation to identify Python overhead, then benchmark alternative paths: Cython+LAPACK layouts, SciPy.linalg.eig with check_finite=False, or specialized algorithms. Preallocate memory and use typed memoryviews to eliminate allocation costs. Validate all results against reference implementations.

Can I use SciPy.linalg.eig for faster eigenvalue computation on small matrices?

SciPy.linalg.eig can improve performance by disabling finite-value checking with check_finite=False, reducing overhead on small matrices. However, for maximum speed on matrices 2x2–100x100, Cython with direct LAPACK calls and typed memoryviews typically outperform SciPy by eliminating remaining Python wrapper costs.

What are the limitations of optimizing eigenvalue solving for small matrices?

Optimization benefits apply primarily to matrices roughly 2x2–100x100; larger matrices favor standard library routines where LAPACK dominates total time. Cython+LAPACK requires correctness validation and profiling to ensure gains justify implementation complexity; results are matrix-dependent and tied to dense storage assumptions.

Do I need to validate results when using Cython and LAPACK for eigenvalues?

Yes, correctness testing against reference implementations is essential when using optimized LAPACK paths. Validate that eigenvalues and eigenvectors match numpy.linalg.eig within numerical precision tolerances before deploying Cython+LAPACK optimizations to production.