Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Cross Product In Matrix Form

Abierto
#970 4 comentarios 1 reacción 0 asignados Ver en GitHub

@manvendra5345 ya está trabajando en esto.

Desde el 15/1/2026.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
42/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Área
backend

Línea de trabajo

Read src/stdlib_linalg_cross_product.fypp and src/stdlib_linalg.fypp, which the issue links as the existing cross product and module definition entry points. Check how cross_product() is exposed and tested, then follow that pattern for the proposed matrix function. Done means the function returns the stated 3×3 skew-symmetric operator matrix for a 3-element vector and is available through the linear algebra module.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

idea
Motivation

A proposal to include a cross_product_matrix() function in stdlib_linalg module that takes a 3×1 vector and returns the 3×3 skew-symmetric cross product operator matrix which is used in mechanics a lot to convert the cross product into a linear algebra operator.

An illustrative example of this function would be:

    pure function cross_product_matrix(a) result(c)
    real(dp), intent(in) ::a(3)
    reaL(dp) :: c(3,3)
    real(dp) :: x,y,z

    x = a(1)
    y = a(2)
    z = a(3)
    ! define column-by-column (negative of row-major display)
    c = reshape( &
        [ 0._dp,  z,                -y, &
                  -z, 0._dp,         x, &
                   y,        -x, 0._dp], [3,3])
    end function cross_product_matrix

This allows a vector cross producrt c=a×b to be described using linear algebra as the matrix-vector multiplication c=A*b where A=a× is the cross product matrix.

The use of this function would be in mechanics. For example building a 3×3 rotation matrix from an axis vector and an angle scalar

    pure function rotation_matrix(axis, angle) result(R)
    real(dp) :: R(3,3)
    real(dp), intent(in) :: angle, axis(3)
    real(dp) :: ax(3,3)

        ! Form an identiy matrix
        R = 0._dp
        R(1,1) = 1._dp
        R(2,2) = 1._do
        R(3,3) = 1._dp

        ! Form the cross product matrix
        ax = vector_cross_matrix(axis)

        ! Rodrigues Rotation Formula
        R = R + sin(angle)*ax + (1._dp - cos(angle))*matmul(ax, ax)

    end function rotation_matrix

or finding the mass moment of inertia tensor of a body based on the parallel axis theorem

    pure function parallel_axis_theorem(I, m, r) result(Ip)
    real(dp) :: Ip(3,3)
    real(dp), intent(in) :: I(3,3), m, r(3)
    real(dp) :: rx(3,3)

        ! Form the cross product matrix
        rx = vector_cross_matrix(r)

        ! Parallel Axis Theorem
        Ip = I - m*(matmul(rx, rx))
    end function parallel_axis_theorem
Prior Art

Existing cross product function cross_product() takes two vectors and returns their cross product vector as a result.

https://github.com/fortran-lang/stdlib/blob/2bdc50ee09c90919804ef5b4e24a1eef5faa1d9f/src/stdlib_linalg_cross_product.fypp#L4

and the linear algebra module definition file:

https://github.com/fortran-lang/stdlib/blob/2bdc50ee09c90919804ef5b4e24a1eef5faa1d9f/src/stdlib_linalg.fypp#L4

Additional Information

No response

Lenguaje dominante
Fortran
Estrellas
1.4k
Forks
233
Merge medio
4 d 11 h
PR fusionados (30 d)
5

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de fortran-lang/stdlib

Todos los issues de fortran-lang/stdlib

Issues similares

Más issues de Backend & API Design

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.