laurent.orseau
2019-8-5 07:54:21

Quick test: (require flmatrix/example) on Debian, fails with: ffi-lib: couldn't open "/System/Library/Frameworks/vecLib.framework/Versions/Current/vecLib.so" (/System/Library/Frameworks/vecLib.framework/Versions/Current/vecLib.so: cannot open shared object file: No such file or directory)


laurent.orseau
2019-8-5 07:55:25

Looks like a macos path, not a linux path


laurent.orseau
2019-8-5 07:59:49

It’s installed in: $ locate liblapack.so /etc/alternatives/liblapack.so.3-x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/liblapack.so.3 /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3 /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.8.0 /var/lib/dpkg/alternatives/liblapack.so.3-x86_64-linux-gnu


laurent.orseau
2019-8-5 08:00:06

sorry, can’t test more for now


laurent.orseau
2019-8-5 08:05:49

but you should probably rely on the PATH instead


laurent.orseau
2019-8-5 09:20:39

(on phone, on the train) Actually, can’t you just use ffi-lib without a specific path?


soegaard2
2019-8-5 10:32:17

Thanks for trying this.


laurent.orseau
2019-8-5 10:32:20

For example this just works for me: (define cblas-lib (ffi-lib "libblas" '("3" #f))) (define lapack-lib (ffi-lib "liblapack" '("3" #f)))


soegaard2
2019-8-5 10:33:10

So, don’t load veclib, but load libblas and liblapack instead?


laurent.orseau
2019-8-5 10:33:34

yeah, that works for me


laurent.orseau
2019-8-5 10:33:37

I tried the example


laurent.orseau
2019-8-5 10:33:41

on Debian


soegaard2
2019-8-5 10:33:49

Thanks again.


laurent.orseau
2019-8-5 10:33:58

np


laurent.orseau
2019-8-5 10:40:55

Instead of (define epsilon 1e-13) shouldn’t you use something like flulp? https://docs.racket-lang.org/math/flonum.html#%28def._%28%28lib._math%2Fflonum..rkt%29._flulp%29%29


soegaard2
2019-8-5 10:41:57

Maybe. Depends on what epsilon was used for. It’s old code, so I can’t remember.


soegaard2
2019-8-5 10:42:10

But I need to check.


jarcane
2019-8-5 10:44:39

I have something of a philosophical question with respect to the design of OOP systems, and as this is something where I’m slightly limited in experience, I could use some perspectives from those who use OOP languages as I’ve not even really got anything readily at hand to test with.

The question is this: when handling object inheritance, should the child of an object be able to overwrite the fields of the parent object? IOW, should the following psuedo code be valid and result in a Bloo with fields { bar: int, baz: int}, or should it be an error: object Foo { bar: int, baz: str } object Bloo extends Foo { baz: int } Formerly, the Heresy language said “yes”, somewhat by accident. But the recent implementation of a new feature has somehow broken this behavior, but I’m not sure this is a bad thing because it seems to me that allowing that behavior would break the guarantees of inheritance, ie. that you can expect the methods shared between parent and child operate the same.

Thoughts? How do other OOP languages usually handle this? Especially ones that retain a functional focus like Scala or Racket.


soegaard2
2019-8-5 10:51:02

laurent.orseau
2019-8-5 10:54:18

The tests at the end of the file can nowadays be in a (module+ test ...) submodule instead of commented out?


mark.warren
2019-8-5 10:59:09

@jarcane In Java this would be called shadowing. By redefining baz in the child it has it’s own field called baz. It would also somewhat depend on the access level of the parent fields. If baz was private then the child could never directly affect it (only through setters), if it was protected then the child could change it through using super.


laurent.orseau
2019-8-5 11:02:25

Implicit shadowing can be risky, debugging-wise. The principle of least surprise would suggest that such behaviour should be unauthorized by default, except if a special keyword is used.


jarcane
2019-8-5 11:05:22

Yeah. I dimly recall some language having an override keyword, maybe Java or Scala, that let you do it but you had to then declare it explicitly at least


mark.warren
2019-8-5 11:07:25

Java’s @Override only applies to methods not fields. I would personally avoid shadowing and make any fields in the parent private so that they can only be changed at the parent level through methods of the parent.


soegaard2
2019-8-5 11:07:34

Yeah. I put it up in the hope someone would use it and modernize.


jarcane
2019-8-5 11:08:02

as a very fun counterexample, in JS classes, you can break the field of a parent object by changing the field in its child:


soegaard2
2019-8-5 11:08:15

But I think Peter Samarin is working on a matrix library.


jarcane
2019-8-5 11:08:27

this seems like a good example though of what not to do


laurent.orseau
2019-8-5 11:12:08

The math/arrays lib doesn’t seem too bad either, since I believe it doesn’t require to write types for everything, just what uses the arrays


soegaard2
2019-8-5 11:13:31

True. And that supports arrays of different number types.


soegaard2
2019-8-5 11:14:08

Numerical matrix is tricky though - and people have spent a lot of time and effort in writing CBLAS and LAPACK.


soegaard2
2019-8-5 11:14:20

Which means that these libraries are trusted.


laurent.orseau
2019-8-5 12:28:36

Indeed. I encourage you to finish this :slightly_smiling_face:


nma.arvydas.silanskas
2019-8-5 13:42:02

java’s override annotation isn’t required btw. It’s more of a sanity check for when you try to override non-existant parent method


mark.warren
2019-8-5 13:56:26

@nma.arvydas.silanskas That is very true, it is more of a sign of intention than anything else, I was just pointing out it only applies to methods and not fields. I don’t know if any other language has this idea.


laurent.orseau
2019-8-5 14:01:41

You got me, I couldn’t resist converting to rackunit :wink:


soegaard2
2019-8-5 14:05:40

Thanks!


soegaard2
2019-8-5 14:05:55

So the existing test for qr failed?


soegaard2
2019-8-5 14:07:18

Wikipedia writes that for a square matrix: If A is invertible, then the factorization is unique if we require the diagonal elements of R to be positive.


laurent.orseau
2019-8-5 14:08:07

indeed, the results I obtain are negative numbers


laurent.orseau
2019-8-5 14:08:25

I don’t know why you get negative numbers though


soegaard2
2019-8-5 14:09:43

how do I run the file from the terminal if I want to run the rackunit tests?


laurent.orseau
2019-8-5 14:11:33

raco test flmatrix.rkt I think


soegaard2
2019-8-5 14:11:33

I get negative numbers too (ran it in DrRacket).


soegaard2
2019-8-5 14:16:18

I see a couple of todos in flmatrix-qr, so it probably never returned the canonical result.



laurent.orseau
2019-8-5 14:25:55

Not your fault it seems


laurent.orseau
2019-8-5 14:27:01

Ok, I found the fix


laurent.orseau
2019-8-5 14:27:07

super simple


laurent.orseau
2019-8-5 14:27:12

I’ll send a pull request


soegaard2
2019-8-5 14:27:24

great!


bill_temps
2019-8-5 15:01:50

@mark.warren @jarcane Note that there is a difference between overRIDing the name of a field, and overWRITing the contents of a field. In my experience with OOP, overriding is expected; overwriting is almost always discouraged.


jarcane
2019-8-5 15:46:55

Well, in my use case, fields can be overridden, but the original object is at least unaffected


jarcane
2019-8-5 15:50:50

So you can do (describe Foo (bar 1)) (describe Baz extends Foo (bar "sac")) and Foo remains the same, but Baz will have the new value but with the same field names and also return true for (is-a? Foo Baz) because it’s still a child of Foo


krismicinski
2019-8-5 16:17:34

Oh goodness this is totally a question that illustrates the difference between higher-order and flat environment structure


krismicinski
2019-8-5 16:17:52

But unfortunately I do not know how to explain this intuitively quite yet..


spdegabrielle
2019-8-5 17:07:17

winny
2019-8-5 17:21:41

Is there an easy way to do fixed-width java numerics style bit mangling in Racket? Some approaches that come to mind: (1) always enforce the integer length with a bitwise-and to the desired length after each manipulation (2) do something with bitsyntax (3) there is a bitvector implementation in rosette, but it doesn’t work with typed racket https://docs.racket-lang.org/rosette-guide/sec_bitvectors.html?q=bitwise#%28part._.Bitwise_.Operators%29 My use case is to encode/decode minecraft varints: https://wiki.vg/Protocol#VarInt_and_VarLong I have working code that correctly encodes and decodes nonnegative values, but the encoder runs in an infinite loop on negative integers, and my encoder doesn’t appear to shift the sign into the sign bit. (Implementation https://github.com/winny-/minecraft-ping/blob/master/varint.rkt#L17-L71 )

Any suggestions or tips to achieve negative integer encode/decode to/from varints would be appreciated =)


winny
2019-8-5 17:25:24

I am starting to wonder if i shouldn’t just implement java numerics using a vector of bits (each represented as a boolean) and write logic that manipulates their contents instead. Hoping to avoid that if at all possible


bill_temps
2019-8-5 18:02:20

@jarcane In Java, the principle of encapsulation generally discourages allowing direct access to any data fields from outside an object; instead, all access is through getter and setter methods. In that case, the situation you describe never happens: the child’s “baz” and the parent’s “baz” are just totally separate entities that happen to have the same name, and neither would be accessible to any external entities. (There is also a current trend in Java in favor of making objects immutable.) A quick test found that Java (Standard Edition :sunglasses: doesn’t complain if a child has a field with the same name as a field in the parent, even if they have different types. They behave as entirely separate. If the parent field is public, the child can change it, but if the parent field (“baz”) is private, the Java compiler issues an error message if the child tries to access it directly.


jaz
2019-8-5 18:22:08

@winny It does tend to get a bit tricky with the sign bit, since the generic bitwise operators treat Racket integers as infinite-length twos-complement bitstrings. And you can’t use the fixnum variants, because they don’t work with the bit-widths that you need. Something like this works: https://gist.github.com/97jaz/2884d660bb16d006a2c099639ec4b893


jaz
2019-8-5 18:23:54

There are really only two deviations from the pseudocode: (1) the signed-var-int proc, that checks the sign bit and converts to negative when necessary, and, in the writing proc, masking the value, so that we don’t loop forever.


soegaard2
2019-8-5 21:14:22

@spdegabrielle Looked up Studio Visual Code at Wikipedia. To my surprise they use Electron. Also: “In the Stack Overflow 2019 Developer Survey, Visual Studio Code was ranked the most popular developer environment tool, with 50.7% of 87,317 respondents claiming to use it”.


spdegabrielle
2019-8-5 21:43:59

@soegaard2 yes - and electron seems to be a combination of chromium and nodejs. It appears to be crazy popular. but notepad++ is also popular.


soegaard2
2019-8-5 21:47:54

I was surprised. As far as I know Atom is also built with Electron - and it is called slow (and Electron is blamed).


spdegabrielle
2019-8-5 21:48:34

@soegaard2 the slack desktop app is also in electron.


soegaard2
2019-8-5 21:49:22

The Visual Studio Code blog shows how much work they are doing: https://code.visualstudio.com/updates/v1_36


spdegabrielle
2019-8-5 22:12:48

contributors are microsoft staff. Deep pockets. they also ahve second place with vs


spdegabrielle
2019-8-5 22:12:51

Visual Studio 31.5% Notepad++ 30.5% IntelliJ 25.4% Vim 25.4% Sublime Text 23.4%


soegaard2
2019-8-5 22:40:23

Grammar question: Should the gap between rings be called: ring-gap or rings-gap?


d_run
2019-8-5 23:49:23

VS code has made major inroads, especially in the JavaScript community. It’s TypeScript tooling is top notch (because, you know, Microsoft.)


sorawee
2019-8-5 23:54:57

I like ring-gap. And yes, I’m the worst person to ask about English grammar :slightly_smiling_face:


ijcguy1
2019-8-6 02:26:57

@ijcguy1 has joined the channel


winny
2019-8-6 06:54:08

Thanks! This appears to be exactly what I need. One shortcoming that comes to mind is Fixnum doesn’t appear to let one use a 64-bit Fixnum on 32-bit platforms. But Maybe I shouldn’t worry about this for now…. I could also just simulate it with two fixnums of 32-bit width. (Later on I want to implement VarLong which is a 64-bit wide minecraft data type.)