> I am currently looking into finding a good numerical library as our
> basis for developing a generic C++ library for probabilistic modeling
> and inference. I compared several libraries: MTL4, Armadillo, and
> Eigen, and now NT2, and actually did some programs with Eigen.
> However, I found that NT2's basic design seems to be much better than
> Eigen (IMHO), in terms of consistency, extensibility, and the beauty
> of syntax.(I haven't done extensive benchmark, so I don't know which
> would have better run-time performance)
Well, depending on code, we should be comparable to Eigen. Now, we have
a larger support for modern architecture (namely AVX instruction set and
a larger application of multi-core acceleration) that may play in our favor.
> The main concern with NT2 is the lack of documentation. And it takes
> great efforts to trace into the source codes to figure out stuff.
> Fortunately, I have many years of experience working with MATLAB, and
> NT2 seems to have a similar interface, so I can guess a lot of things
> from my MATLAB knowledge.
The documentation is an active topic at the moment and will be completed
during
upcoming weeks. And yes, we aims at having a 1:1 mapping with matlab
interface
as long as C++ syntax allows us.
> I understand that NT2 is still under development, and not completely
> ready for release. However, I still would like to try it and not wait
> until it is ready ( I can work around with the lacking functionalities
> by myself.)
Sure
> 1. Are basic interfaces for table ready and stable?
> e.g. numel, ndims, size, �
Yes
> What if I want to get the number of rows and columns, size(A, 1) and
> size(A, 2) ? or there are more direct method like nrows(A) and
> ncols(A) ?
size(A,n) works and we provide some shortcut for height(a) and width(a)
> 2. Are arithmetic and basic linear operations ready ? (+, -, *, /)
Yes
> Particularly, how to write element-wise multiplication and matrix
> multiplication respectively? (C++ doesn't allow things like (.*).
Matrix multiplication is still to be fixed interface-wise but the
gist will be something like :
* between scalars is an elementwise operation
* between scalar and matrix is also elementwise
In other case, we use our internal type categorization to figure out if
mtimes or times should be applied.
More over, we mimics the non-operator name from matlab, so times and
mtimes will be available
if you really want to enforce one or the other.
> Are there an element-wise square function?
sqr(x) yes
>
> 3. Are element-wise elementary evaluation functions ready ? (exp, log,
> sin, cos, etc)
Yes, we support more than 200 mathematical functions (see the various
modules contents).
basically all libm, ieee related functions, basic arithmetic and some
more niche operations like
bessel functor and some special exponentiation functions.
In most case we're on par or slightly better than MKL in terms of
performances and we're always
better in term of precision. We have an extensive test suite over
precision of functions.
> 4. Does it have something like bsxfun (broadcast evaluation)?
> Particularly, I often have to do things like adding/multiplying a
> vector to each row/column of a matrix.
Not yet but it's on our roadmap. Interface for the function object is
still to be decided.
>
> 5. How to write range indexing, like A(1:2:5, :) and A(:, 1:4) ? Even
> further, does it support indexing with a supplied index vector, say
> A(:, [1, 4, 6, 7, 9]);
Simply put, whenever you use : in matlab, nt2 will require you to use _.
So :
A(1:2:5, :)
becomes
A(_(1,2,5), _ )
Indexing is supported for scalar, _ and simple 1D indexer. Some bugs are
being fixed
at the moment for supporting the other cases. What we miss now is a
proper syntax for
[ 1 2 3 .. ]. This one is still in discussion and well, opinions welcomed ;)
> 6. Does it support logical indexing ? like A( A> 0 )?
Planned but not done yet.
> 7. Are the following linear algebraic operations ready ? matrix
> product, LU, QR, Cholesky, SVD, and eigenvalue/eigenvectors
> (particularly those for symmetric matrices), log-determinant, and
> linear solver.
Not yet, the linear algebra module is in active development at the
moment. Once some general interface
issues are fixed, we'll starts integrating them during upcoming weeks.
> 8. Does it use BLAS/LAPACK back-end (such that I can link with MKL)?
> (if it is optional, is there a macro to enable it?)
Yes. The Cmake build script takes care of detecting which BLAS/LAPACK
flavor is available
and use it transparently. In case you want to specify one special
back-end, the cmake script
can be fed with the direct path to your back end of choices.
Except for exotic platforms like embedded systems, we'll rely on
external libraries for such
specialized kernels.
> I am really serious looking into using NT2, and hope this doesn't seem
> to be too many questions.
No problems :)
> (Perhaps you may set up a simple wiki page
> or something that roughly sketches the basic functionalities and
> whether they are ready, which would be greatly helpful )
Yes this is something we consider. We'll probably starts using the
Milestones
tracking on github too.
> Finally, I am wondering when it is going to be released (several
> weeks? months, or a year?) I understand this might be too early to
> tell, but is there a rough estimation?
We're aiming at having some Release candidate at the beginning of
this summer with a significant subset of functionalities and architectural
support.
Thanks again and feel free to ask us any questions :)
>> 2. Are arithmetic and basic linear operations ready ? (+, -, *, /)
> Yes
Actually, element-wise operations yes, matrix multiplication and
division (* and /) not completely usable yet.
>> 5. How to write range indexing, like A(1:2:5, :) and A(:, 1:4) ? Even
>> further, does it support indexing with a supplied index vector, say
>> A(:, [1, 4, 6, 7, 9]);
>
> Simply put, whenever you use : in matlab, nt2 will require you to use _.
> So :
>
> A(1:2:5, :)
>
>
> becomes
>
> A(_(1,2,5), _ )
>
> Indexing is supported for scalar, _ and simple 1D indexer. Some bugs are
> being fixed
> at the moment for supporting the other cases. What we miss now is a
> proper syntax for
> [ 1 2 3 .. ]. This one is still in discussion and well, opinions
> welcomed ;)
Things like 1:2:5 (which is not contiguous) probably has a few problems
still.
The problems are due to us trying to vectorize everything whenever
possible (AVX2 can perform a gather operation here), which is tricky to
do with indexing.
I believe this. Also, I think using VML of MKL has several problems,
which are deal-breakers for me:
(1) When we want to process a large number of short vectors (say
length < 20),
it seem to have huge overhead, and it shows benefit only when it is
invoked to
process a large sum of elements each time.
(2) It is eager evaluation, meaning that it scans the entire vector
for each single operation.
In my domain, I often have to chain a series of arithmetic/exp/log
computation, and this would be
a performance penalty. That's why I am looking at C++ libraries that
make use of expression template techniques to reduce such overhead.
I am impressed by the full set of functions provided by NT2, which
is unparalleled among C++ numeric libraries.
Whereas I think the syntax bsxfun(@plus, a, b) (as in MATLAB) is
useful
in general, this way may need to decide how to process a and b at run-
time
(i.e. to tell which dimensions need to be broadcasted/expanded)
Ideally, I wish it can support such syntax:
A(I, J)
Here, I and J are anything that supports random access iteration (e.g.
std::vector),
then I can build up I and J in my own way (using whatever random-
access container
I see fit in my context).
Does it provide a find function at this point? say find(A > 0) and
returns index vectors.
Oh, I did not notice the Cmake detects such (maybe I am missing
something).
I did have an MKL (ver 10.3) installed and MKLROOT set as environment
variable.
Is there a way for me to inspect which back-end the installed NT2 lib
is using (e.g. looking at some header files to see which macros are defined ?)