Skip to content

Add Support for "Building Blocks" #7

Closed

Description

@RoyiAvital

A way to represent auxiliary atoms:

  1. Vector of ones.
  2. Identity matrix.
  3. Diagonal of a matrix (Extracting).
  4. Diagonal from a vector (Forming).

Activity

  1. asterycs commented on Jun 2, 2025

    @asterycs
    Owner

    Hi! For number 3 - would you want to extract the diagonal of an existing matrix or create a new matrix with a vector on the diagonal?

    For 1 and 2 - the internals are now implemented. Vector of ones was needed also for element-wise log. However, the user facing API is missing, I'll add it soon.

  2. RoyiAvital commented on Jun 2, 2025

    @RoyiAvital
    Author

    I guess both.
    Edited to make it clear.

  3. RoyiAvital commented on Jun 2, 2025

    @RoyiAvital
    Author

    I guess the operator Vec() is also needed.

  4. asterycs commented on Sep 1, 2025

    @asterycs
    Owner

    All of these are now implemented:

    julia> using DiffMatic
    
    julia> using LinearAlgebra
    
    julia> to_std(gradient(vector(2)' * x, x))
    "vec(2)"
    
    julia> to_std(jacobian(matrix(2) * x, x))
    "mat(2)"
    
    julia> to_std(gradient(diag(A)'*x, x))
    "(A ⊙ I)vec(1)" # same as 'diag(A)', better output is todo
    
    julia> to_std(jacobian(diagm(A*x)*x, x))
    "diagm(Ax)I + diagm(x)A"
    
    julia> to_std(gradient(x' * I * x, x))
    "2x"
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions