[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,>> HANNELI TAVANTE: Fun time.\NIs the connector safe?\NShould we borrow another one?\NDon't panic.\N(Pause). Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Okay . Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Hi, I'm Hanneli.\NI'm from Brazil, I'm a software developer and as our friend told us, I started the Rust in Sao Paulo care.\NToday, we have about 300 members, which is something.\NWe have been running the meetups for around a career and we can proud a meetup almost every month, and some are happy to see we are growing and usually, we have some volunteers front some interesting topics, such as implementing genetic alrhythms with Rust, implementing the basic concept of the language with pokeman.\NWe had this talk.\NSo I'm happy to see this community growing.\NDuring my free time, I like to do these things here.\NI like pokeman.\NSo if you're playing pokeman go, we can walk around the city to catch some pokeman. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,So this presentation is about rewriting code in a talk called octave F.\Nyou're not familiar with octave, I'm going to talk about this in the further slides.\NBut as a bonus, even if you are not working directly with Rust, I expect that by the end of the talk, you have an idea of transforming some math concepts into your code.\NIn ray very expressive way I'm going on show you step by step, how we started building some codes in Rust for active.\NSo this is going to be, kind of, you know, addressed so there is some code that actually doesn't run.\NIn the last slide I'll leave you with reference so can you get the code from GitHub and run it.\NI think nobody is requesting to be scared about the math that there is this presentation and to help us to keep firm until the dinner time.\NLet's start taking about some training tools and science.\NTraining tool in science are becoming very popular probably has consequence, some of these tools, based on Corcera.\NEverybody here didn't know what scorecera?\NDoesn't.\NIt's very popular.\NEDX is another popular, too.\Npeople who are develop developers, people who do not have a background, it's pretty exciting.\NThis is like bringing topics like data analysis, big data, to people who are not connected with research.\NWhich is pretty interesting.\NI was talking to some students, that graduated maybe last year.\NAnd they were telling me, they use some of the tools to help them with mathematics.\NSo one is octane and it can help you, if you are for example, electrical engineer trying to solve some crazy and differential equations for very difficult and you need hands on software to provide support.\NI pretty much like Coctave.\NBut I had difficult times, during my under grad year when is I was doing research.\NI usually had a problem to resolve, low frequency inverseer, trying to figure out how to implement that I would spend a lot time on things that have nothing to do with the Ochave.\NFor example, I was getting a tangle or I forget to reallocate memory and everything blowup want that was kind of frustrating to me.\NI'm not saying like, this happens to everybody.\NBut you know, very hard and difficult time.\NAnd pretty much, all the other tools were open source would provide meet same problem.\NI had trouble to extend the functionalities of the tool.\NAnd I was surprised because when I ask the students if they like it, they say yes.\NBut we have trouble to express mathematics, with C and C++.\NThat's the case you end upping a lot of time or something else, rather than spending time with your problem.\NThen I started to think about the possibilities that we could adapt to resolve it.\NI was studying Rust at that time.\NVersion 1.0 was just released.\NI spoke about Rust and they accepted to try the language and see if it could help them with the problems that they were facing.\NSo Octave if you're not familiar with the two is pretty much useful for machine learning for data analysis.\NFor maybe, something, some calculations that it needs to do with computer vision and things like this.\NIt's useful for example, operations with matrices, body charts, statistics, and several other areas that have some heavy population sets, you know, you don't want to resolve everything by hand.\NA good point about Ochave is it is open source.\NAnd open source is pretty good.\NIt usually extends the existing libraries and things like this. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,This is what usually happens when you're doing research.\NThere's a point when you need to add your code to an existing, too.\NFor example, there are lots of external publics that people bell for Octave and they are available on GitHub or any other source repo.\NThen can you easily, you know, add your contribution to the tool.\NWhich is amazing.\NBut sometimes it's not easy to handle.\NA very famous data structure is this one.\NIt's very likely that's one date.\NAt any point of your life, you receive this spreadsheet.\NAnd a spreadsheet is a table.\NSo we have to handle tables or better, matrices, in several scenarios, several distinct scenarios, right?\NWhy matrices are so important.\NEverybody Sundays me spreadsheets.\NNo.\NNot only because of that.\NMatrices, they can represent us in several different areas, and sometimes you're not aware that you can represent something with a matrice.\NBut you actually can.\NSo, I guess one of the first context taw had with matrices, was in high school.\NBut not sometimes, not even in mathematics, math classes, was something else.\NTo remember this law here?\NOhm's law.\NYou have this, you have the voltage and then have you this relation, other resistance in the voltage.\NAnd then, you can make this even more sophisticated.\NI'm happy because it talks about [indiscernible] today.\NSo, I guess it's scared of this.\NEven if you failed in physics class, you might remember something like a circuit with voltages for the resistance.\NBy the way, those are the [indiscernible] flaws.\NYou have a bunch of equations and find a value for every variable that you V and involve it in the system.\NSo there's some work and figure out what the value is for, the resistance 1, 2 and so on.\NBut for linear systems, there is an alternative representation, rather than this one with the curly brackets.\NYou can represent with matrix.\NAnd there are advantages of representing linear systems as matrices.\NWe can apply several different rules.\NFor example, there is what you call the turn -- several different reduce of finding properties of a linear system.\NSo understanding a little bit about matrices helps us a lot to resolve linear systems.\NAnd linear systems, they are a structure which is, which you can find in several different areas.\NFor example, electrical engineering.\NEnvironmental initialing, healthy environments, behaves in things like this this is part of the code you have to represent an array or a matrix in compiler.\NThis is the code base for array and a class called matrix.\NThis is a very expensive code.\NIt has around 500 lines, something like that.\NAnd it's pretty much plate coderation. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,So those students that were talking last year, I asked them what, is the most frequent structure that you use in octave. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,How would you build a matrix in Rust?\NVector.\NBut a vector, how would you build your own?\NCome on.\NYou know that truck.\NLet's build this truck called matrix.\NMakes sense.\NMakes a lot of sense.\NSo tell me, what's going to be.\NThink about a matrix.\NThink about this matrix here that you were on the right side of the screen.\NYou have rules.\NYou have goals.\NAnd there is something inside the matrix, which are the matrix elements.\NThat makes sense.\NAnd this is simple.\NThis is the very first step that you have, in trying to build a representation a matrix.\NMakes a lot of sense. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,We started discussing something else.\NSo for example, you can remember your math classes, when you multiply matrixes, can you multiply any matrix with any other matrix if no, there's a rule.\NSo on the right side, you have a matrix with two rows and on the left side, a matrix, with three rows and 4 columns.\NCan we multiply this matrix tricks?\NYes.\NThe number of column equals the number of row in the second matrix.\NSo yes, we can multiply this.\NWhat's going to be the dimension of the output matrix we have some rules, based on the matrix.\NInteresting.\NWe have to keep checking.\NDid I mention, every time but this is what you do in C++ because of the template.\NYou have to keep checking all the time.\NThis is not very convenient.\NHow can we prove this code?\NWe want to add some behavior.\NStructure.\NSo this is a bad representation.\NDon't do that. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Instead, create a trade.\NCall dimension.\NThat makes sense.\NYou can ask all the behavior, based on the dimension of a matrix inside this code and this is going to be much more explicit when you give Rust to matrix you don't have chief Pence trying to, you know, perform an operation with matrix, with dimensions that did not match.\NThis is pretty interesting.\NI was reading something on the Internet.\NSo there is a link, at the bottom of the page.\NAnd he suggested that we should use phantom data, when we were presenting a matrix and that makes sense.\NCan you picture in your head, a matrix without any element?\NDoesn't make much sense.\NIs this kind of thing doesn't exist.\NAnd this author was saying something like, you should have elements representation.\NWhich you can do by using phantom data or you can create your own type of matrix elements.\NKind of doesn't matter.\NBut this presentation of a matrix is kind of much better.\NAnd much more well structured than our nation presentation where we had rows, columns and something pretty vague for data this is how the end yearis I.\Nimplemented.\NAny kind of array has been mentioned, as elements. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Next challenge.\NCan you think of codes to represent clear matrices?\NDoes it make sense to have a code for matrices, in terps of the common and most used mathematical properties that have for matrices in yes, makes sense to utilize squared matrix.\NBase on the matrix itself.\NYou can fix the dimensions.\NSo the dimensions are always equal want and then you can derive a bunch of code from this initial code.\NSo its pretty convenient for us.\NAnd with that.\NI hope you had a very quick overview of why linear is important and why matrix are important.\NAnd I really hope you can follow the main idea of how we get a mathematical concept and we apply this to Rust.\NThat was our very first attempt in the final codes, that we're using, was pretty much like this one.\NAnd everybody's kind of happy with that.\NAnother important structure that students research this a lot.\NComplex numbers.\NIf you come from an initialing backgrounds, you're very likely to have seen a lot complex numbers.\NDo you know why there is a reason for people to keep using complex numbers.\NDo you know why?\NI mean, a good explanation, because they like T.\Nthere's there's an imaginary part that's a school.\NThis is not a good good, you know, this is not a good point.\NFor example, computer, which is a very nice subject.\NEverything is based on complex numbers.\NIt's easier to differentiate.\NThat is one point.\NBut you can differentiate different numbers as well.\NOf minus 1.\NSo there is a more generic reason to use that.\NLet's talk about this.\NThis is kind of the off-topic moment of this lecture.\NBut I hope that after it session, you share with everybody why you use those numbers.\NThere's a single mathematical reason for this eqivalence.\NWhy doesn't it exist?\NThis is true.\NThis is true that makes everything much more simple.\NLet's talk about this. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Let's start from the beginning.\NIntegers.\NI'm happy because of the very fist keynote of this morning, we were talking about integers, and real numbers.\NBut we didn't reach the complex numbers, which are so important.\NSo when you add an integer to another, what is the output?\NAnent jer.\NGlad glad it's an integer.\NSo when you're talking about the operation, the output equals input.\NTo the type.\NBut that's not true.\NWhen you're talking about division.\NIf you divide an integer by an integer, what happens?\NYou may not have an integer as a result.\NMay not.\NThere is a chance it is, but there's a chance it's not.\NI added the letters that correspond to each set by hand.\NIt's pretty August ugly.\NI'm sorry about that there is a set.\NWhich if you're not familiar of the other sets.\NYou can easily copy this concept from the keynote headed this morning.\NWhat is the most inclusive set that can be using.\NThey're real numbers want okay.\NCool the numbers.\N0 is annex collusion.\NDon't consider that. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,There is something even more generic than divided by 0.\NIs there any other operation you can think of, somebody already told the answer.\NYes.\NThere is an operation you provide input and you might not end up with this one as the output when you're looking for a square root of a number.\NIf you're look for example a square root of -4.\NThe result is not going to be a minor number.\NSo this is sad.\NSo the thing here is like, complex numbers we say they are closed for the most common operations.\NSo if somebody says that this operation is closed, you can be sure that staying put is going to be as the same type of the output.\NAnd this is convenient for functional programming if you're talking about types you weren't sure of the output, the type of the output, and you can, you know, dereef lots of things about that.\NCan we express this property with code?\NYes.\NIt's not difficult.\NFor example, you can have this structure here, called complex number, that has the real and imaginary parts and all the mathematical operations are going to result in a complex.\NSomething like this.\NThis is pretty much straightforward and convenience.\NMaybe sure the existing types are closed operations in a certain scope.\NWhich is very convenient for several operations and initialing.\NSometimes engineering, want to be sure that the output is going to be equal to input.\NThis is much true.\NThink about T.\NRust is very powerful.\NYou cannot have the behavior.\NEven for existing types.\NThere's probably somebody doing that.\NBecause the biggest tools you have for initialing, they still using using imperative programming or if some language, that sometimes you cannot have this level.\NIt just create ace trait, and that's to an existing type. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,The complex numbers are already part.\NSo you do not have excuses to keep usings open stats for your most common operations.\NI think I still have time.\NI don't know who's counting the time.\NBut some lessons learned.\NThere are really great skills to help mathematics, in terms of engineering and general science.\NBut I don't know about you, but I've been struggling with the tools for a long time.\NBesides math lab and compiler, for example, we have VHDL.\NIt's the language that describes harbor.\NIf you think about VH -- couldn't we be using Rust to strike hardware.\NBased on the sessions to date, yes.\NBut could Rust become a substitute for VHDL?\NMaybe, yes.\NI had a very hard time with trouble that I couldn't, I simply could not represent that and maybe with Rust, we could improve over the system in general.\NFor me, it was pretty sad to change my focus.\NI was trying to solve a problem.\NHow can I optimize the trails of the circuits and I should resolve this and this and this.\NTrying to solve dangly pointers or something I did in the middle of the code.\NThen it was not very productive to me.\NIt was kind of time consuming from my research is something that should be training my time of that research.\NI had a very difficult time and sometimes I wanted to add behavior, an existing type, so I had to create another class with another set of descriptions, and things like this and with Rust, I don't have this problem anymore.\NWhen I learned highway to program, the examples were like with animal.\NClass animal.\NAnd nobody taught me how -- nobody tells me, hey, here's, I don't know a differential equation.\NNow you get this equation, and transform this.\NPeople voter to say, now you use numerical methods.\NOf course they can represent that.\NI was just using the wrong language, but there is a way to represent the mathematical structures in a more natural and straightforward way.\NOne last, but not least point I was so happy, the compiler was telling me something, that something was wrong before I'd run T.\Nsomething very frustrating to me is like, compiler can be slow for some operations and I was writing an operation in compiler and boom.\N.\NI wanted to cry.\NI lost 10 minutes to get a runtime error.\NI was really sad with that and some of the problems can be avoid for us.\NWith the certain types, the Rust compiler can tell you, hey, don't do that because it's wrong.\NI don't have the responsibility anymore.\NI just 38 throw the responsibility to the compilers in certain cases.\NConnecticut collusion I took from there talk to the students is like, why don't you have many people join that.\NSo we have concepts and mind sets, based on the thought that can be applyd to other areas.\NFor example, a mathematical concept, but we can apply that to, I don't know, maybe payment.\NThink about it.\NSo maybe you can maybe if you can describe mathematical property, more easily and more trait forward in a programming language, maybe we can start using laws of mathematical concepts, on a daily base.\NSometimes I see lots of young people asking, why do you have to study Calculus.\NSometimes it's not obvious.\NHow can you be applying these concepts in real-life problems and maybe problems of what developments or I don't know, payments or products and things like this.\NBut if we had a more convenient way to describe mathematics, into programming, maybe we can spread this knowledge across, you know, other areas of the industry.\NAnd maybe you can make them more popular.\NWell, that happens.\NSo I share the good parts and I'm going to share the things that went wrong or almost wrong.\NSo request I started learning about Rust I said oh.\Nthere's this thing called unsafe and I'll probably never use that.\NIf you need to integrate Rust with another language.\NSometimes you need to use unsafe and I found myself, like every time I had a problem, I'd type this mag call word at the beginning.\NSometimes yes F you're doing a full baggage of language, C or python, there is, you can have your unsafe methods or your unsafe function but you should not expose that so you have something else safe.\NLet the method handle the possible problems that it might end up W.\NI'm telling this, because I was aware of this but you know, my body refused to do it.\NIt was much more convenient to type them safe, until somebody uses the library and says, Oh, everything is broken.\NWhy.\NIt works on my machine.\NSo make things safer, it's good advice. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,There was another example.\NSafe and unmute F.\Nit's not working, just add mute and everything will be fine.\NYou have fun time, which gates signal, which represents on time, and you opt with that as a signal of frequency.\NAnd the same for the case, you have a signal frequency, and back to signal time.\NSo I was use something libraries, because mine was not working so I decided to [indiscernible] mutable aces.\NI was happy with that.\NIn terp in terms of concept, you're settling something mutable.\NOnce you have the sampling of a signal, it's never going to change.\NSo it doesn't make sense in terms of code.\NSo I was writing a convenient code in terms of programming but it's a code that doesn't make sense at all.\NIn terps of presentation.\NSo when you're going to write.\NWhen you're going to write, think about this.A oh.\Nwait.\NDoes it make sense.\NIt doesn't make sense to represent a mutable signal with mute, for obvious reasons.\NActually handle your construct into the perfect way.\NSo I'd like to use some references here.\NThe tool for linear algebra, and I was reading the source code.\NYou can actually find some structures that are pretty much the same as the once we saw at the beginning of this presentation.\NYou're going to see that inside of phantom data, they have, a bump of interesting approaches to handle any kind of array of end dimensions.\NThere are also some papers about Rust types and how can like how these types can help you or science tools.\NIt's the FTP link you see there.\NAnd of course, some well known references like the nome.\NLike the dots.\NAnd there is one very interesting and probably also well known one.\NI don't know if you edit here.\NNo.\NDidn't.\NI can edit later.\NIt's a tool about FFT in Rust.\NSo some special thanks to Florian.\NI'd like to add, no, no more [indiscernible].\NBruno is also help being the Brazilian community, and thoughtworks has been hosting most of our meetups.\NFor my mentor, Daniel.\NAnd for these people who provide me gifts and of course, for the Brazilian Rust community.\NThank you and I don't know if I have time for questions.\NWe don't have time for questions.\NTy.