Skip to content

Instantly share code, notes, and snippets.

@astrojuanlu
Created May 13, 2012 19:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save astrojuanlu/2689795 to your computer and use it in GitHub Desktop.
Save astrojuanlu/2689795 to your computer and use it in GitHub Desktop.
Símbolo de Levi-Civita en Python
# coding: utf-8
# Símbolo de Levi-Civita en Python utilizando listas por comprensión
# Fórmula extraída de http://en.wikipedia.org/wiki/Levi-Civita_symbol#Three_dimensions
# Válido para Python 2 y 3
#
# Juan Luis Cano Rodríguez <juanlu001@gmail.com>
from __future__ import print_function
import numpy as np
e = np.array([[[int((i - j) * (j - k) * (k - i) / 2) for k in range(3)] for j in range(3)] for i in range(3)])
print(e)
[[[ 0. 0. 0.]
[ 0. 0. 1.]
[ 0. -1. 0.]]
[[ 0. 0. -1.]
[ 0. 0. 0.]
[ 1. 0. 0.]]
[[ 0. 1. 0.]
[-1. 0. 0.]
[ 0. 0. 0.]]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment