# What are the differences between numpy arrays and matrices? Which one should I use?

From what I've seen, either one can work as a replacement for the other if need be, so should I bother using both or should I stick to just one of them?

Will the style of the program influence my choice? I am doing some machine learning using numpy, so there are indeed lots of matrices, but also lots of vectors (arrays).

40

As per the official documents, it's not anymore advisable to use matrix class since it will be removed in the future.

https://numpy.org/doc/stable/reference/generated/numpy.matrix.html

As other answers already state that you can achieve all the operations with NumPy arrays.

Tuesday, June 1, 2021

100

If you'd like something a bit more readable, you can do this:

``````A = np.squeeze(np.asarray(M))
``````

Equivalently, you could also do: `A = np.asarray(M).reshape(-1)`, but that's a bit less easy to read.

Sunday, June 6, 2021

95

`sigma.resize()` returns `None` because it operates in-place. `np.resize(sigma, shape)`, on the other hand, returns the result but instead of padding with zeros, it pads with repeats of the array.

Also, the `shape()` function returns the shape of the input. If you just want to predefine a shape, just use a tuple.

``````import numpy as np
...
shape = (6, 6) #This will be some pre-determined size
sigma = np.diag(S) #diagonalise the matrix - this works
sigma.resize(shape) #Resize the matrix and fill with zeros
``````

However, this will first flatten out your original array, and then reconstruct it into the given shape, destroying the original ordering. If you just want to "pad" with zeros, instead of using `resize()` you can just directly index into a generated zero-matrix.

``````# This assumes that you have a 2-dimensional array
zeros = np.zeros(shape, dtype=np.int32)
zeros[:sigma.shape[0], :sigma.shape[1]] = sigma
``````
Wednesday, August 11, 2021

62

I wouldn't use WiX for a new project. I'd use an 'Installer Project' in Visual Studio to build an MSI. An installer project is much, much easier to put together.

Many exe installers are actually stubs or containers that hold an MSI, btw.

I guess you've checked out http://en.wikipedia.org/wiki/Windows_Installer?

MSI's give administrators the ability to restrict installs, rebase installs, change or add custom actions, automate installs/reinstalls/uninstalls, standard logging and switches. It just really integrates into a corporate IT environment ( http://technet.microsoft.com/en-us/library/bb742606.aspx ).

A custom installer may have many of those features, but that would depend on the installer package.

Monday, September 27, 2021

74

The first contains a bundled ADT version of Eclipse.

This is simply a packaging convenience. You are welcome to obtain Eclipse separately and add Android tooling to it.

Android Studio, the second IDE, is based on IntelliJ.

At the present time, this is an early-access preview. IMHO, it is not suited for someone who does not have experience in Android application development.

Apart from these differences I can't get if there is anything that I can do with only one of them

At the present time, Android Studio is an early-access preview, meaning that there are lots of things that it does not have integrated in. Now, by this time next year, and hopefully far sooner, Android Studio will have equivalent or superior integration than does Eclipse with the ADT plugin.

and what's the point of having two distinct official IDEs.

There are an infinite number of "official" tools. You are welcome to use a plain text editor and tools outside of any IDE, for example.

You are welcome to watch the Google I|O 2013 video on developer tools, where they describe a bit of the rationale behind the development of Android Studio.

Thursday, October 7, 2021