TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Why I sometimes like to write my own number crunching code

67 点作者 dragandj将近 4 年前

7 条评论

Zababa将近 4 年前
I wonder if sometimes always telling people to not do anything themselves and use already made libraries is robbing the industry (and especially juniors) of lots of opportunities to learn. Instead of being in control of what you do, you learn to use something made by other people to simplify things. This is a bit like cooking where in the last 10-20 years I've seen appliances appearing everywhere. Some are very good (I love my slow cooker), some I'm more perplexed about (A stand mixer? I usually get by either with my hand for dense doughs like pizza or bread or a hand mixer for more liquid/light doughs). If everybody uses libraries, how are we training new libraries writers? Maybe part of the solution would be to tell people to use libraries, and then read the code, try to understand them and contribute.
评论 #27646856 未加载
评论 #27650214 未加载
dagw将近 4 年前
Another case where writing your numerical algorithms can be faster than using the standard lib is if you know you&#x27;re only working on a small subset of the possible input domain and can write a highly specialized function.<p>For example, a certain function may take arbitrary dimensional complex matrices as input. However if you know that you will only be passing in 3x3 Real positive semidefinite matrices you can probably write a faster function that only works on those matrices by using all that extra information you have. In Matlab I&#x27;ve gotten order of magnitude speedups over the standard functions by rolling my own highly specialized functions.
lordnacho将近 4 年前
The author has written books about this area, so he&#x27;s pretty confident that he can write numerical libs. That might be right, but for most people, when you come across some need, that&#x27;s going to not be your speciality.<p>I might need a numerical lib at some point, but I also know that there are things like numerical instability, gremlins in this area that I know some of but not all of.<p>Something popular with lots of people working on it is likely to be far better for me than rolling my own.<p>Of course this does mean that for most things by far, the best way forward is to research which lib is best supported and go with that.
mjburgess将近 4 年前
It seems like there&#x27;s been a crash in the FP language market: Scala, F#, ... Clojure.<p>Anyone any idea why?<p>Scala 3 almost looks <i>attractive</i>.
评论 #27644441 未加载
评论 #27642962 未加载
评论 #27649824 未加载
评论 #27642824 未加载
im3w1l将近 4 年前
So uhm why did the cosine similarity give values bigger than one in the library and how can we be confident that this code does not have that issue?
评论 #27647988 未加载
评论 #27643732 未加载
tectonicfury将近 4 年前
I felt that it was a good article, very straightforward, and he made an interesting point about numerical packages being often written by graduate students.<p>Personally, I would like to learn the math, but I would want to first learn from the &#x27;established&#x27; books (i.e. the books the author read on his way to this point), only then will I be in a position to judge the real worth of the author&#x27;s books.
queuebert将近 4 年前
The author is overconfident and underestimates library writers to a fault. Packing a bunch of dot products into a matrix is only the fastest way to compute a batch of cosine similarities if you are relegated to a parallel matrix product function.<p>If you write the procedure in raw CUDA, for example, it is faster to simply broadcast the dot products across threads. That is exactly what the matrix multiply is doing except without the overhead of matrix creation and with potentially greater locality of memory accesses.<p>Edit: I do think it is worthwhile to write your own code so that you better understand what is happening under the hood, so good on the author for that.
评论 #27643372 未加载
评论 #27646094 未加载
评论 #27643296 未加载