I believe you want numpy.linalg.matrix_power
As a quick example:
import numpy as np x = np.arange(9).reshape(3,3) y = np.matrix(x) a = y**3 b = np.linalg.matrix_power(x, 3) print a print b assert np.all(a==b)
This yields:
In [19]: a Out[19]: matrix([[ 180, 234, 288], [ 558, 720, 882], [ 936, 1206, 1476]]) In [20]: b Out[20]: array([[ 180, 234, 288], [ 558, 720, 882], [ 936, 1206, 1476]])
Related Posts:
- Import Error: No module named numpy
- How do I read CSV data into a record array in NumPy?
- How do I read CSV data into a record array in NumPy?
- Factorial in numpy and scipy
- TypeError: cannot unpack non-iterable int objec
- Overflow Error in Python’s numpy.exp function
- Overflow Error in Python’s numpy.exp function
- Moving average or running mean
- Moving average or running mean
- Official abbreviation for: import scipy as sp/sc
- IndexError: index 2 is out of bounds for axis 0 with size 2
- ImportError in importing from sklearn: cannot import name check_build
- How to add a new row to an empty numpy array
- Root mean square of a function in python
- Compute a confidence interval from sample data
- ImportError: cannot import name NUMPY_MKL
- How to normalize a NumPy array to within a certain range?
- Numpy Resize/Rescale Image
- Sorting arrays in NumPy by column
- TypeError: zip argument #2 must support iteration
- numpy/scipy/ipython:Failed to interpret file as a pickle
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- ImportError: DLL load failed: The specified module could not be found
- ImportError: DLL load failed: The specified module could not be found
- ValueError: setting an array element with a sequence
- numpy max vs amax vs maximum
- What exactly does numpy.exp() do? [closed]
- Difference between import numpy and import numpy as np
- What is the purpose of meshgrid in Python / NumPy?
- why numpy.ndarray is object is not callable in my simple for python loop
- numpy division with RuntimeWarning: invalid value encountered in double_scalars
- Numpy ValueError: setting an array element with a sequence. This message may appear without the existing of a sequence?
- numpy: Invalid value encountered in true_divide
- python numpy ValueError: operands could not be broadcast together with shapes
- How to fix ‘Object arrays cannot be loaded when allow_pickle=False’ for imdb.load_data() function?
- How do I create an empty array/matrix in NumPy?
- Most efficient way to find mode in numpy array
- ValueError: Unknown label type: ‘continuous’
- TypeError: unhashable type: ‘numpy.ndarray’
- How to fix IndexError: invalid index to scalar variable
- Could not install packages due to a “Environment error :[error 13]: permission denied : ‘usr/local/bin/f2py'”
- numpy division with RuntimeWarning: invalid value encountered in double_scalars
- How does numpy.newaxis work and when to use it?
- numpy matrix vector multiplication
- Converting list to numpy array
- data type not understood
- How do you do natural logs (e.g. “ln()”) with numpy in Python?
- Plotting a 2D heatmap with Matplotlib
- How to normalize a NumPy array to a unit vector?
- Should I use np.absolute or np.abs?
- What does numpy.random.seed(0) do?
- ImportError: numpy.core.multiarray failed to import
- What does the c underscore expression `c_` do exactly?
- Convert pandas dataframe to NumPy array
- ImportError: Missing required dependencies [‘numpy’]
- Unable to plot Double Bar, Bar plot using pyplot for ndarray
- Error: all the input array dimensions except for the concatenation axis must match exactly
- ImportError: numpy.core.multiarray failed to import
- How to count the occurrence of certain item in an ndarray?
- size of NumPy array
- Singular matrix issue with Numpy
- Python Pandas – Missing required dependencies [‘numpy’] 1
- numpy array concatenate: “ValueError: all the input arrays must have same number of dimensions”
- How to find all occurrences of an element in a list
- TypeError: ‘numpy.float64’ object is not callable
- TypeError: ‘numpy.float64’ object is not callable
- ‘DataFrame’ object has no attribute ‘sort’
- Convert a tensor to numpy array in Tensorflow?
- ‘DataFrame’ object has no attribute ‘sort’
- Convert a tensor to numpy array in Tensorflow?
- ValueError: all the input arrays must have same number of dimensions
- ValueError: setting an array element with a sequence
- filename.whl is not a supported wheel on this platform
- Using Numpy Vectorize on Functions that Return Vectors
- Use a.any() or a.all()
- TypeError: ‘numpy.float64’ object is not callable?
- ‘DataFrame’ object has no attribute ‘sort’
- Convert a tensor to numpy array in Tensorflow?
- How to normalize a NumPy array to a unit vector?
- convert nan value to zero
- What is dtype(‘O’), in pandas?
- A tool to convert MATLAB code to Python
- ‘End of statement expected’ in pycharm
- How can I upgrade NumPy?
- Most efficient way to map function over numpy array
- What does numpy.gradient do?
- Is there a NumPy function to return the first index of something in an array?
- How can the Euclidean distance be calculated with NumPy?
- How to get element-wise matrix multiplication (Hadamard product) in numpy?
- Numpy/Python Array Value error
- ‘list’ object has no attribute ‘shape’
- What is dtype(‘O’), in pandas?
- initialize a numpy array
- ValueError: could not broadcast input array from shape (224,224,3) into shape (224,224)
- TypeError: ‘DataFrame’ object is not callable
- load csv into 2D matrix with numpy for plotting
- Cannot convert list to array: ValueError: only one element tensors can be converted to Python scalars
- How can I use numpy.correlate to do autocorrelation?
- ValueError: ‘object too deep for desired array’
- Calculating Covariance with Python and Numpy