libmir / mir

Mir (backports): Sparse tensors, Hoffman
http://mir.libmir.org
Boost Software License 1.0
210 stars 20 forks source link

higher level more user friendly shell on top of GLAS #327

Closed timotheecour closed 6 years ago

timotheecour commented 8 years ago
nothrow @nogc Slice!(2, C*) gemm(C, A, B)(GlasContext* ctx, Slice!(2, A*) asl, Slice!(2, B*) bsl, C alpha=1.0, Conjugated conja = Conjugated.no, Conjugated conjb = Conjugated.no){
  size_t[2] shape;
  //TODO
  auto c=sliceUninitialized!C(shape);//cf https://github.com/libmir/mir/issues/325
  gemm(ctx, alpha, asl, bsl, 0.0, c, conja, conjb);
  return c;
}

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/37819203-higher-level-more-user-friendly-shell-on-top-of-glas?utm_campaign=plugin&utm_content=tracker%2F18251717&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F18251717&utm_medium=issues&utm_source=github).
9il commented 8 years ago

Furthermore, we need new hight level wrapper with global context.

timotheecour commented 8 years ago

is operator overloading too magical? a*b as in matlab downside: could be hard to search

alternative that's more searchable and extensible:

glas!"*"(a,b) // matrix multiplication
glas!".*"(a,b) //elementwise multiplication (or division, etc)
glas!"\"(a,b) // same as a\b in matlab (linear solver)
// for addition: "+" or ".+" ?
9il commented 8 years ago

is operator overloading too magical?

Yep, because they should be a part of Slice struct.

alternative that's more searchable:

glas!""(a,b) // matrix multiplication glas!"."(a,b) //elementwise multiplication (or division, etc)

Looks good

timotheecour commented 8 years ago

also: as in matlab, could automatically dispatch the best algorithm depending on arguments, except at compile time instead of runtime:

works with sparse/full a or b, (a or be matrix or vector of compatible dimensions), can exploit hermitian symmetry or other properties known at compile time (cf https://github.com/libmir/mir/issues/329 specifying symmetricFromUpper)

glas!"*"(a,b)
jmh530 commented 8 years ago

@9il I like glas!"*" as a starting place, but I think operator overloading for the most common matrix operations is a positive. Many other packages (Armadillo) do this. It makes heavily numerical code much prettier. For instance, compare glas!"*"(glas!"*"(P, sigma), P.transposed) with P*sigma*P'. And it eases the transition for people coming from other languages.

9il commented 8 years ago

@jmh530 I am not against it. But it should be build on top of ndslice and glas.

jmh530 commented 8 years ago

@9il Ah, okay then.

9il commented 6 years ago

no plan to add the package into the main Mir repo Maybe related to the Lubeck package.