Skip to main content

No project description provided

Project description

vector-structure

PyPi version Documentation Status

Lightweight utilities for working with structured flat vectors and block matrices in NumPy.

Example usage

Consider a Newton algorithm for solving the KKT conditions, as described here:

$$\begin{pmatrix} \nabla^2 f(x) & \color{gray}{Df(x)^T} & A^T \ \color{gray}{-diag(\lambda) Df(x)} & \color{gray}{-diag(f(x))} & \color{gray}{0} \ A & \color{gray}{0} & 0 \end{pmatrix} \begin{pmatrix} x^* \ \color{gray}{\lambda^*} \ v^* \end{pmatrix} = \begin{pmatrix} \ \dots \ \end{pmatrix}$$

where the grey components are only required when inequality constraints are present.

from vector_structure import VectorStructure

structure = [("x", n)]
if ineq_constraints:
    structure.append(("lambda", m))
structure.append(("mu", p))

vs = VectorStructure(structure)

M = np.zeros((vs.size, vs.size))
M[vs["x"], vs["x"]] = nabla2(f)(x)
if ineq_constraints:
    M[vs["x"], vs["lambda"]] = Df(x).T
M[vs["x"], vs["mu"]] = A
...

x_lambda_mu = np.linalg.solve(M, r)
x = x_lambda_mu[vs["x"]]
if ineq_constraints:
    lambda = x_lambda_mu[vs["lambda"]]

For the full documentation, see here

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vector_structure-2.4.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vector_structure-2.4.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file vector_structure-2.4.0.tar.gz.

File metadata

  • Download URL: vector_structure-2.4.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vector_structure-2.4.0.tar.gz
Algorithm Hash digest
SHA256 861d02c51fb416684849f2cffcd56345ae76d5b0f49306b394795ad732e4e767
MD5 7ded3d71a2f91e72f086afdcf0e2f9a8
BLAKE2b-256 c90cc6597740cf09e61a7349d959abc414bb6e2ce88b219375c918761d0e1098

See more details on using hashes here.

Provenance

The following attestation bundles were made for vector_structure-2.4.0.tar.gz:

Publisher: python-publish.yml on Warggr/vector-structure

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vector_structure-2.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vector_structure-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c7a69582e8aa989fe17e6c85e4ade8e3078b3f03628427de8de3d4d278c995e2
MD5 f65459db72ef84b075bb7e52140ade28
BLAKE2b-256 0b4812c22f439a154b6b7addb5bd5b6c7d9b68de8726fd422b7c099d8c898d69

See more details on using hashes here.

Provenance

The following attestation bundles were made for vector_structure-2.4.0-py3-none-any.whl:

Publisher: python-publish.yml on Warggr/vector-structure

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page