C++ STL numeric - transform_reduce | Modern Cpp Series Ep. 185

Поділитися
Вставка
  • Опубліковано 17 чер 2024
  • ►Full C++ Series Playlist: • The C++ Programming La...
    ►Find full courses on: courses.mshah.io/
    ►Join as Member to Support the channel: / @mikeshah
    ►Lesson Description: In this lesson we take a look at std::transform_reduce -- which combines what we have learned in transform and reduce operations. Again the advantage of this algorithm has to do with being able to potentially being able to transform and reduce the data in one step, as well as potentially do that step in parallel (as opposed to doing all transforms first, and then a second reduction step). This is a powerful algorithm that I have frequently observed in high performance computing and image processing. Two 'gotcha's' remain 1. make s sure the initial type matches your result (as this is determined at compile-time by the template parameter type) 2. Make sure the default value for the constructed type is what you want it, if you choose the overload that omits 'init'. Note that you may have also heard of this algorithm as 'map-reduce'.
    ►UA-cam Channel: / mikeshah
    ►Please like and subscribe to help the channel!
    ►Join our free community: courses.mshah.io/communities/...
  • Наука та технологія

КОМЕНТАРІ • 8

  • @MyMjrox
    @MyMjrox Місяць тому +1

    I like your C++ series. A request to make a series on C++ build system (CMake, Make, etc).

    • @MikeShah
      @MikeShah  Місяць тому +1

      Cheers -- that is a popular request I, I have an outline of lessons I could do, still thinking about it.

  • @pecdo1262
    @pecdo1262 Місяць тому +1

    This was a wonderful video, thank you very much :3

  • @Chupe_chupe
    @Chupe_chupe 2 місяці тому +1

    Thanks a lot for this great vídeo

    • @MikeShah
      @MikeShah  2 місяці тому

      Cheers, you are most welcome!

  • @imtootired4122
    @imtootired4122 2 місяці тому +1

    Is there a reason you use "return v *= 2;" instead of just "return v * 2; " ?

    • @MikeShah
      @MikeShah  2 місяці тому

      I believe return v*2 would be fine. Just have to be careful not to modify the actual element (which is not happening here) -- so 'return v*2' should be perfectly fine (and probably preferred!)