Question: After being a MATLAB user for many years, I am now migrating to python.

I try to find a concise manner to simply rewrite the following MATLAB code in python:

```
s = sum(Mtx);
newMtx = Mtx(:, s>0);

```

where Mtx is a 2D sparse matrix

My python solution is:

```
s = Mtx.sum(0)
newMtx = Mtx[:, np.where((s>0).flat)[0]] # taking the columns with nonzero indices

```

where Mtx is a 2D CSC sparse matrix

The python code is not as readable / elegant as in matlab.. any idea how to write it more elegantly?

Thanks!

Answer: 
C++ compilers generally expect the command line option `-std=c++11` (or `-std=c++0x` for slightly older ones, respectively) to activate C++11-support.

> 
> not supporting C++11 style at all.
> 
> 
> 

No, it perfectly does. GCC 4.7.2's support can be [checked here](https://gcc.gnu.org/gcc-4.7/cxx0x_status.html). To activate some experimental features, pass `-std=gnu++11`.

And Clang 3.4 actually supports pretty much everything [in C++11 and already much out of C++1y](http://clang.llvm.org/cxx_status.html).
One alternative that does not involve typedef and is not strongly enforced by the compiler but makes it very hard for the programmer to make mistakes it to encode the unit in question as a struct member.

For my arduino project I have types like

```
template <typename T>
struct millisecond {
    T millisecond;
    static constexpr const struct millisecond<T> zero = { 0 };
};

template <typename T>
struct microsecond {
    T microsecond;
    static constexpr const struct microsecond<T> zero = { 0 };
};

```

and use like

```
auto time_diff = millisecond<unsigned long>::zero;
time_diff.millisecond = nowMilliseconds() - s_lastPollTime.millisecond;

```

So with this strategy the compiler does not stop you from mixing units, but if you do then the error will always [scream at you](https://www.joelonsoftware.com/2005/05/11/making-wrong-code-look-wrong/):

```
total_expenses.euros = expence1.euros + expence2.dollars;

```