Comments (9)
See also #9
from mir.
Hmm I like your idea of overloading opCall
, but it works only for element access.
What do you think about something like the following?
(the last two are proposed)
It should basically work similar to opIndex then ;-)
auto s = iota(4).sliced(2,2);
s[].writeln; // [[0, 1], [2, 3]]
s().writeln; // [0, 2], [1, 3]]
s(1).writeln; // [[0,2]]
from mir.
Hmm I like your idea of overloading opCall, but it works only for element access.
Yes, first we need a good DIP for opCall to be like opIndex. See http://wiki.dlang.org/DIPs
It should basically work similar to opIndex then ;-)
Behavior with .writeln
looks bad to me. opCall should only select sub-dimensions without any transpostion.
from mir.
Yes, first we need a good DIP for opCall to be like opIndex. See http://wiki.dlang.org/DIPs
I guess one could use iota
instead of ..
, apart from that variadic arguments should be supported ;-)
Behavior with .writeln looks bad to me. opCall should only select sub-dimensions without any transpostion.
What would you suggest s(1)
should return then?
from mir.
I guess one could use iota instead of .., apart from that variadic arguments should be supported ;-)
Anyway $
is not defined for opCall
What would you suggest s(1) should return then?
s().writeln; // [[0, 1], [2, 3]] instead of [[0, 2], [1, 3]]
s(1).writeln; // [0, 2] instead of [[0,2]]
from mir.
Anyway $ is not defined for opCall
You could also overload with tuples and replace the $
with -1
s = iota(9).sliced(3, 3);
// 0 1 2
// 3 4 5
// 6 7 8
// 0 3 6
// 1 4 7
// 2 5 8
s(tuple(1,2), tuple(1, 2)); // [[4,7], [5,8]]
s( tuple(1,-1), tuple(1, -1)); // same
Oh sry - made the brackets for s(1)
by mistake.
For s()
I am not sure yet, but by looking at the examples with everted
above, I notice two things
b.everted.reshape(2, 3).everted
b().reshape(2, 3)(); // similar, but definitely harder to read
-
the
opCall
syntax is quite hard to distinguish/read and to understand whats going on. Why not add a simple method, e.g.b.F(2, 3)
(probably better naming required though) -
The main point of this issue was that in the examples the math index order is not stored, leading that
b.everted.reshape(2, 3).everted
evaluates differently than maybe expected and one needs to make a copy of the array..
from mir.
You could also overload with tuples and replace the $ with -1
-1
would significantly reduce performance.
from mir.
-1 would significantly reduce performance.
and if i think about it one couldn't do stuff like (2, $-3)
from mir.
duplicate of #10
from mir.
Related Issues (20)
- Special optimization for compile time known kernels HOT 1
- Separable filters support for DCV HOT 1
- Package mir contains invalid dependency cpuid (ci=1) HOT 5
- libmir.so missing from .gitignore HOT 1
- cannot infer argument types, expected 1 argument, not 2 in opApply on Slice HOT 2
- auto a=[[1,2],[3,4]].ndarray; // how to do that? (doens't compile) HOT 3
- Error: cannot append type int[] to type Slice!(2LU, int*) HOT 2
- mir vs ndslice conflict in dmd vs ldc when compiling with dub on ubuntu HOT 2
- Tiny Mersenne Twister HOT 1
- regression test to make sure at least latest dub versions work? currently broken HOT 1
- dot, norm, asum to mir.math.sum HOT 1
- mir-random does not compile with latest ldc on raspberry pi HOT 4
- How to reference the library HOT 6
- FFT? HOT 1
- OpenCL implementation? HOT 1
- can't understand how `sliced` definition compiles HOT 3
- Failing on Buildkite HOT 3
- rand!float() exponent problem HOT 3
- mir-algorithm dependency fails to build because of mir-core with ldc2 and gdc HOT 4
- Deprecation warnings
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mir.