Mojo Programming Language || Matrix from Scratch

Поделиться
HTML-код
  • Опубликовано: 12 ноя 2024

Комментарии • 32

  • @mekkanix
    @mekkanix Год назад +9

    I Learned a lot about operator overriding, oop, the practical use of parameter keywords like inout, borrowed, and owned, c-style memory management/ pointers in mojo, and much more. Tutorials like this are hard to find this early on in the life of a new programming language, and I appreciate your pioneering efforts and your effective explanations. I look forward to your future videos!

  • @IvoBalbaert
    @IvoBalbaert Год назад +3

    Don't mind the length. These are really good videos, excellent pace, very clear. Thank you!

  • @bismillahsultani7729
    @bismillahsultani7729 3 месяца назад

    Bro this is so cool. Your mice is also pretty good in this video compared to your old videos !

  • @grzegorzryznar5101
    @grzegorzryznar5101 Год назад +4

    I like this series much more since it explains concepts new comparing to Python. Waiting for videos explaining system - level stuff like parameters / compile time stuff / inlining etc :)

  • @gerocastano8
    @gerocastano8 3 месяца назад

    In the equals function, you should first check if the dimensions of the two matrices are the same. Otherwise, you may be accessing elements out of bounds from the other matrix.

  • @mohameddwedar4261
    @mohameddwedar4261 Год назад +3

    Very wonderful, one of the few people who have begun to explain this new language. We are waiting for more from you and waiting for the Machine learning and deep learning course in the Mojo language

  • @gerocastano8
    @gerocastano8 3 месяца назад

    When you define the operators for addition, subtraction and multiplication with scalars, does it matter in which order you put them into the expression? I ask because you always name the argument "rhs", and I don't know if you could put the rhs on the left side.
    E.g., when coding, can you do "matrix + \lambda" as well as "\lambda + matrix"?

  • @MultiNeurons
    @MultiNeurons Год назад +4

    Nice, but there is a bug in the __init__()
    you should specify self.total_items = self.width * self.height and not width * height because.
    The actual width and height of the table are the "self" ones and changed to 1 if passed a zero.
    For a sake of completeness I would test the allocation and the actual size of the array.

    • @activelearning4386
      @activelearning4386  Год назад

      Thank you for your feedback! You are right!

    • @osogrande4999
      @osogrande4999 11 месяцев назад

      @@activelearning4386Not the only bug. if loc > self.total_items is also wrong. should be >=

  • @Cookstein2
    @Cookstein2 Год назад

    you've overloaded your __mul__ method for scalar multiplication of your matrix e.g. M*2;
    Will you need to implement __rmul__ in order to be able to right multiply by a scalar e.g. 2*M
    also, its defined currently for rhs: Float32; does it need overlaods for all the other scalar types (Int, Flaot64...)?

    • @activelearning4386
      @activelearning4386  Год назад +1

      Yep, so you have to implement a separate method if you want to do 2*M. I believe there are generics to work with in mojo. It's been a while since I programmed in mojo. You could check out the documentation page.

  • @RIZAMOHAMMAD-n5s
    @RIZAMOHAMMAD-n5s Год назад

    Which theme of visual studio are you using

    • @activelearning4386
      @activelearning4386  Год назад +2

      This is the theme: marketplace.visualstudio.com/items?itemName=pmndrs.pmndrs

  • @atrocitus777
    @atrocitus777 Год назад

    would you be able to do a video on implementing a dictionary in mojo? I know the standard library doesn't have them but i'm sure with stucts you and fancy pointer magic it could work. I tried to use register passable pointers but still couldn't get it to compile...

    • @activelearning4386
      @activelearning4386  Год назад

      Sure! I will look into it tomorrow!

    • @atrocitus777
      @atrocitus777 Год назад

      @@activelearning4386 amazing thank you! its been bothering me lately because i wanted to run some benchmarks on how a custom made dict using mojo structs would compare to importing a dict using the python interop

  • @manikhossain8728
    @manikhossain8728 Год назад

    Great tutorials
    But I didn't understand why in the __copyinit__ method, you define the type of other to Self rather than Matrix.
    Does the Self indicate to the instantiated object of the Matrix class?

    • @activelearning4386
      @activelearning4386  Год назад

      Self here is used to indicate that the type is the same as the class to which the method belongs. You can also just use Matrix here :) Here's a more in depth guide for Self in python that's applicable to Mojo: peps.python.org/pep-0673/

  • @lukasz443
    @lukasz443 11 месяцев назад

    Hi, in 22:07 you are mistaken. Since you fetched Float32 from the "array" you can compare it with == opeartor.

  • @mushinart
    @mushinart Год назад

    Cool tutorial really...also cool theme ..what is it ?the color coded scopes are nice

    • @activelearning4386
      @activelearning4386  Год назад

      Thanks! This is the theme: marketplace.visualstudio.com/items?itemName=pmndrs.pmndrs

  • @carlcaulkett3050
    @carlcaulkett3050 Год назад

    In your __setitem__ method, your're using the `inout` directive for `self`, on the basis that `self` is going to change. Is this correct? Surely the underlying value of self will stay the same, and only the associated data will change. It may well be that the semantics of Mojo are different, but in Delphi, and Java, `self`, by definition, is immutable!

    • @activelearning4386
      @activelearning4386  Год назад

      Yep, inout just allows you to modify the data associated with self. You aren't changing the entire object that self refers to.

  • @osogrande4999
    @osogrande4999 11 месяцев назад

    Plenty of bugs in this code, and very questionable implementation choices. Example, the __eq__ method assumes rhs is the same dimensions as self. This is my very first look at mojo so I don’t know but isn’t there a simpler memcmp to compare the 2 memory blocks? (not that you should compare floats for equality using a straight == operator anyway, due to precision issues, best to compare for equality within a tolerance for floating point data).

  • @uthoshantm
    @uthoshantm 11 месяцев назад

    Proprietary sh.t. I will never get even close to it, thank you. Julia is a way better choice.