
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)

Looks like a macos path, not a linux path

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

sorry, can’t test more for now

but you should probably rely on the PATH instead

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

Thanks for trying this.

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

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

yeah, that works for me

I tried the example

on Debian

Thanks again.

np

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

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

But I need to check.

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.

Okay, I added code to handle unix. https://github.com/soegaard/flmatrix/blob/master/flmatrix.rkt

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

@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.

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.

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

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.

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

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

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

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

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

True. And that supports arrays of different number types.

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

Which means that these libraries are trusted.

Indeed. I encourage you to finish this :slightly_smiling_face:

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

@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.

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

Thanks!

So the existing test for qr failed?

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.

indeed, the results I obtain are negative numbers

I don’t know why you get negative numbers though

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

raco test flmatrix.rkt I think

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

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


Not your fault it seems

Ok, I found the fix

super simple

I’ll send a pull request

great!

@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.

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

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

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

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

Racket News - Issue 13 https://racket-news.com/2019/08/racket-news-issue-13.html

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 =)

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

@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.

@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

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.

@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”.

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

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

@soegaard2 the slack desktop app is also in electron.

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

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

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

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

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

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

@ijcguy1 has joined the channel

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.)