Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

431
Vistas
Kronecker product of 3 matrices using Python

Suppose that we have 2 2X2 numpy arrays:

X=np.array([[0,1],[1,0]])

and

I=np.array([[1,0],[0,1]])

Consider the Kronecker product

XX=X^X

where I have let the symbol ^ be the symbol for Kronecker product. This can easily be computed via the numpy.kron() function in python:

import numpy as np
kronecker_product = np.kron(X, X)

Now, suppose that we want to compute

XX=I^X^X

numpy.kron() only takes two arrays as arguments and expects them to be the same dimension. How can I perform this operation using numpy.kron() or other technique in python?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

As with anything like this, try:

XX = np.kron(I, np.kron(X, X))

Output:

>>> XX
array([[0, 0, 0, 1, 0, 0, 0, 0],
       [0, 0, 1, 0, 0, 0, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 0],
       [1, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 1],
       [0, 0, 0, 0, 0, 0, 1, 0],
       [0, 0, 0, 0, 0, 1, 0, 0],
       [0, 0, 0, 0, 1, 0, 0, 0]])

You can nest calls to kron any number of times. For example, for XX = A^B^C^D^E, use

XX = np.kron(A, np.kron(B, np.kron(C, np.kron(D, E))))

If you don't like the verbosity there, you could create an alias for np.kron:

k = np.kron
XX = k(A, k(B, k(C, k(D, E))))

Or, better yet, use reduce from the Python built-in module functools to do it in an even more readable fashion:

import functools as ft

lst = [A, B, C, D, E]
XX = ft.reduce(np.kron, lst)

Note: I tested all of this and it works perfectly.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda