Skip to content

Added function slicedExactly - #482

Closed
Iskaban10 wants to merge 3 commits into
libmir:masterfrom
Iskaban10:issues
Closed

Added function slicedExactly#482
Iskaban10 wants to merge 3 commits into
libmir:masterfrom
Iskaban10:issues

Conversation

@Iskaban10

Copy link
Copy Markdown

fixes #313

Comment thread source/mir/ndslice/slice.d Outdated
Comment thread source/mir/ndslice/slice.d Outdated
/++
Creates an n-dimensional slice-shell over an iterator having the exact elemnt count as that of the array.
Params:
iterator = An iterator, a pointer, or an array.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be a dynamic array or an ndslice: those have length.
So you will have two tiny overloads.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. added the second overload👍.
can you tell me why circleci is failing everytime? unable to figure out

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

circleci is deprecated I think

Returns:
n-dimensional slice
+/
auto slicedExactly(size_t N, Iterator)(return scope Iterator iterator, size_t[N] lengths...)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return scope T[] array, keep it simple

@9il

9il commented Aug 27, 2026

Copy link
Copy Markdown
Member

Mir is very strict on API rules. A function with name slicedExactly must not accept raw iterators with no length attached. I would suggest to keep this function at your library. The value of it is low, while the value of math API you are working on can be great. Don't spend your time on mir, it is mostly frozen (or we can say walking dead).

@Iskaban10

Copy link
Copy Markdown
Author

Mir is very strict on API rules. A function with name slicedExactly must not accept raw iterators with no length attached. I would suggest to keep this function at your library. The value of it is low, while the value of math API you are working on can be great. Don't spend your time on mir, it is mostly frozen (or we can say walking dead).

I would need mir for a college project which I was thinking of coding in D. My project would need time-series and I thought working on it for mir would be a good idea. Given mir's current state, I'll work on it then in my own library. Thanks for the review either way.

@Iskaban10 Iskaban10 closed this Aug 28, 2026
@9il

9il commented Aug 28, 2026

Copy link
Copy Markdown
Member

maybe it could be useful https://github.com/libmir/mir-algorithm/blob/master/source/mir/series.d

@Iskaban10

Copy link
Copy Markdown
Author

maybe it could be useful https://github.com/libmir/mir-algorithm/blob/master/source/mir/series.d

Thanks

@jmh530

jmh530 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

@Iskaban10 From the forum thread, I thought your focus was a SAOC project involving mir, rather than a college project. I think my recommendations from the thread might be somewhat different for a college project. With SAOC, it's kind like you have to use D. With a college project, you could conceivably use any language or at maybe pick from a list that the instructor approves of.

From the college project perspective, the question would be more like "how effectively could I do this in D vs some other language". Without knowing more details on your project, I wouldn't be able to say much. I do a decent amount of time series analysis of economic and market data, and I probably use R the most for that. I was trying to build out more functionality in D through mir, but I think the big missing thing in mir is probably improved support for data frames. But depending on what you want to do, the functionality in mir may be sufficient. It's hard to say without knowing more about what you want to do.

I would generally agree with what Lance Bachmeier says on the forum that the more you can pull in from other languages, probably the better. He has tools that lets you interact between R and D for instance. So for instance if you start an R project and find that a part is slow, then you can use his tools to pull in a D function, like with Rcpp. Or vice-versa if you have a D project you can launch an R interpreter and potentially offload some analysis to that.

@Iskaban10

Iskaban10 commented Aug 28, 2026

Copy link
Copy Markdown
Author

Hi @jmh530
My focus was SAOC. I have a college project on structural analysis and optimisation for laminated composites shells (civil engineering background) and for that my professor had asked me to write a minimal finite element solver if possible. I'd also need both the time series and optimisation functionalities for dynamic analysis and structural optimisation. I had made this PR to gain some familiarity about the codebase before I applied.

Since FEA is computationally very heavy and mir is light and fast, I thought of doing something with D. For SAOC I'd only focus on working and contributing to mir, the college project would be a personal project since it requires more time.
I had prepared a draft proposal for SAoC but I am having second thoughts about applying since they might be breaking changes in the mir system. It'd be nice if you and @9il would check the proposal saoc_mir_proposal once.

I'd love to know what you guys think of it and I'll apply for SAoC based on your feeedback. I haven't added anything regarding dataframes in the proposal because I checked there has been previous GSoC work for it but if there's a need or scope for improvements, I'll be more than happy to contribute to this as well.

@jmh530

jmh530 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

@Iskaban10 I'm not too familiar with civil engineering. But one option is always to write that in D and then call it from another language that the other functionality you need. Alternately if you want to keep everything in D, there are optimizers written in C, then you should be able to call them with importC.

On the SAOC, I would defer to @9il on the enhancements to mir-algorithm. Some of the work on mir-stat you are interested in could probably be done without that. For instance, an autocorrelation function would work just fine without having time indices. It might be nice for it to be aware of the time indices, but the actual calculation doesn't need it. You can call acf in R on a regular vector.

@Iskaban10

Copy link
Copy Markdown
Author

Considering the current direction of the mir ecosystem, I think it would be better for me to focus on my college project for now. Since my project already involves many of these numerical problems, I can explore them there and hopefully identify areas where they could later translate into useful contributions to Mir.

Thank you @jmh530 for your suggestions and feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug or feature? sliced.elementCount != arr.length

3 participants