Created
August 15, 2012 20:33
-
-
Save stober/3363364 to your computer and use it in GitHub Desktop.
Sparse Matrix Failure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
""" | |
Author: Jeremy M. Stober | |
Program: ERROR.PY | |
Date: Thursday, August 2 2012 | |
Description: Example of how sparse matrix operations may fail. | |
""" | |
import numpy as np | |
import scipy.sparse as sp | |
A = np.ones((3,4)) | |
np.multiply(A, A[0]) # arrays are ok | |
B = np.asmatrix(A) | |
np.multiply(B, B[0]) # matrices are ok | |
C = sp.csc_matrix(A) | |
np.multiply(C, C[0]) # sparse matrix fails | |
C.multiply(C[0]) # sparse matrix fails |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment