/g/ - Technology

install openbsd

[Make a Post]
[X]





Nanonymous No.3701 [D][U][F][S][L][A][C] >>3705 >>3728 >>3750
File: 0c4bbea1047b06240e3d98f6f13c65f1a73cf9f0e00dbef03d48aa564fce19c5.png (dl) (18.14 KiB)

I make a math library for my own programming language. I want know what functions there should be, but I don't know math.
The library contain sin, asin, sinh, asinh and other trigonometic functions, log/ln/lg/lb, sigmoid, transpose. Also I going to add interpolation and other functions to image/tensor processing. Also I would like to know, if is there application to integration and differentiation of functions. In my language is callable objects, so I can easly replace sin() function to same object, that calls as sin(), and has deriviative and antiderivative functions. I also want know functions to process tensors, such as transpose and interpolation of images, Ghaus what.
Also I want to know about optimizations. At some day I got knowledge how to compute Fibonachi by matrixes, but I didn't understand yet. Also I think about memoization, caching of results.
What do you think?

Nanonymous No.3702 [D][U][F]
File: 7afc5de07f022f2e3ecaa9491fd983f3434ad86192d8b54c7f4b322331ae2f59.jpg (dl) (32.28 KiB)

I make new program language
main concern math with rational number

Nanonymous No.3703 [D]

In my language is float type which is rational number.

Nanonymous No.3705 [D]

>>3701
Read musl libc source

Nanonymous No.3710 [D] >>3716 >>3719

How can you be a programmer yet have such weak math skills?
>interpolation
There are several methods for doing interpolation and different methods have different parameters and different minimum amount of points.
>derivative and antiderivative functions
How do you plan to implement these? Are you always going to be using dual numbers for everything all the time so that you can take the derivative at any time? Or are you planning it to be done symbolically?

Nanonymous No.3716 [D]

>>3710
I was thinking about writing a math lib where every function was defined as it's taylor series. You could easily take derivative, definite integral, any composition of functions, and notably any inverse of a function. Taylor series are accurate over way to small a domain for this to be practical for very much though, so it would end up only a toy.

Nanonymous No.3719 [D] >>3720

>>3710
I was thinking about table data where a function has deriviative and antideriviative, and according to the rules deriviate and antideriviate, if there will be sin function, then sin object has deriviative and antideriviative. Something like this.
Main question is how much useful this would be?

Nanonymous No.3720 [D] >>3722

>>3719
Suppose your table said that the antiderivative for e^x is e^x, and the antiderivative for x^2 is x^3/3. What does your program say the antiderivative of e^(x^2) is?
it doesn't, because such a function has no analytic solution

Nanonymous No.3722 [D]

>>3720
Nothing, maybe.
I meant rules such as + and - if I properly remember, there is splitiing. I don't remember. Integral.
Sorry I can't think because of voices. Now is Easter. Many voices, hate loud voices.
I meant rules such as + and - and in my language classes (No, there is structs and unions. But there is generic. Load voices, load voices. Generc, generic. Yes, thith can't. I don't remember. I hate Easter. Why people do holydays? Holydays isn't important). Okay, walk away and remember.
I remembered. generic have struct or union elements, but the same classes can have same elements, but overloaded operators.
It's not important now. I hate Easter and holydays because of loud voices.
I meant rules such as + and - if I properly remember, there is splitting. And classes for formulas, that can have deriviative and antideriviative.
But I yet not know, is there a profit?

Nanonymous No.3723 [D] >>3724

Why do you need to write a math library?
Can't you just write the language itself, and let the users write their own programs?

Nanonymous No.3724 [D] >>3726

>>3723
Consider 3 cases:
0. A programmer discovered my programming language.
"Hey, why there isn't a math library? Ho to sine and cosine???"
"Is there some input-output library?"
"I wnat to make socket data flow, how???"
1. I make wrapper for C math library. A programmer discovered the programming language.
"Hff, sine, cosine, like at my c plus plus. Language intredasting... I don't want learn this."
2. A programmer-entusiast discovered my programming language, makes a supermath library.
>sine, cosine etc have hardcoded accuracy.
>Using f32e8 (C float, IEEE 754 single) instead of rational float "for speed" because of "calculating speed"
(Compiler must optimizate. If function that takes 2 floats, called with f32e8 in cycle or each constuction (in my PL for parallel programming), there should be compiled fast f32e8 function)
>Not using polymorphism where should, because of "C compatibaltit"
(there is my PL func and C c.func types, in further, cpp.func, python.func etc, so he can make multilangauge support)

Even if I'd make compiler or interpreter for my programming language, it need some libraries. I don't want include .h headers and parse it to my PL parsed datatree.
So, I need firstly make some libraries.
Reserved library names:
audio. Collection of audio formats.
avs. Audio-video-subtitle, collection of videocontainter formats.
c. C types.
dapa. Data parsing, byte strings, text string, numbers.
fs. File System. Directories, files, modes, tags, links, file devices, etc.
io. Input-output to files. Extendable to sockets, representation, maybe something else.
math. Math library.
module. Dynamic module loading. Binary libraries, executable files, scripts.
opengl. OpenGL.
os. OS interaction, malloc, realloc, free, exit.
raising. Python-like exception handling, throwing errors to users.
repr. Representation computer data to human-readable data.
sdl2. SDL2 binding.
socket. Sockets.
stdio. Small file for POSIX (?) stdin, stdout, stderr.
subprocess. Processes like in Python subprocess.
thread. OS threads.
video. Collection of video-formats, including images (PNG,JPG,TIFF), old animations (GIF) and modern video-formats such as H264 (? patenting?), VP8, VP9.

I'm writing compiler with python. pyparsing and llvmlite.
If I make dapa and LLVM library binding, then I would rewrite compiler to my PL.

Nanonymous No.3726 [D]

>>3724
>0. A programmer discovered my programming language. "Hey, why there isn't a math library? Ho to sine and cosine???" "Is there some input-output library?" "I wnat to make socket data flow, how???"
and another shit PL with all thought going into how to make libs and copy C was born

Nanonymous No.3727 [D] >>3731

>@define half as f16e5;
>@define bhalf as f16e8;
>@define single as f32e8;
>@define double as f64e11;

wtf is this, does it let you say any fXeY? like
>@define lol as f24e9;

Nanonymous No.3728 [D] >>3733

>>3701
>Also I going to add interpolation
I'm implementing this right now and you need to write it in assembly for it to be fast enough. All video and image processing right now is either done in hardware or optimized SIMD assembly. Optimizing PLs are dead.

Nanonymous No.3731 [D]

>>3727
Yes, In my language you can choose uN, sN, rNeM, fNeM with any bits. It's unsigned int, signed int, unsigned float-point, signed float point. First integer is bits, second is mantissa. Also there is int — integer, float — rational and string — bytes, that isn't static sized.
fNeM, I haven't figured it out yet. Bit fields corresponds to same as IEEE 754. I know about representation, where NaN/-NaN, infinity/-infinity. About single (f32e8) and double (f64e11) people in wikipedia writed. I don't know, is it architecture-dependent, operations.
I can write in documentation of my language, that behavior of operators to fNeM and rNeM is undefined, but same as on target architecture if such type supported (frequently half and single on GPU, single on ARM, single and double on AArch64, single, double, maybe 40-bit and 80-bit on x86-64).

Nanonymous No.3733 [D][U][F]
File: 18b6b90b48de30b78bf0ea79399cf95761dc45cdf1700bd08dfa317febe215d8.png (dl) (62.85 KiB)

>>3728
>you
No, you! I would take you contibuting, when my compiler-interpreter prepared.
Libraries of my language can have source code, manifest and compiler-module. Source code is source code of the library. My language normally is interpreted, but can be compiled. Manifest keeps data about binary library static and dynamic linking. And compiler-module is loaded module that can manipulate code and compilation as it wants. It's profitful in language-supporing module, such as C c library, imported with @import c!;. Yes, It's unsafe. I'm going to make my site about language and there will be library of libraries from me and other authors if they want when write. I wouldn't add binary compiler-module that not from me, but source-code-module such as pythonic or my PL if it can be loaded by compiler.

Okay, I just wrote some draft functions:
linErp — linear interpolation. If I remember propely, formula is y = y0 + (y1 - y0)*x, where y1 > y0 and x is [0,1].
biLinErp — bilinear interpolation. If I understood well, N-dimensional linear interpolation is linear interpolation of prev products, so I wrote
nLinErp — linear interpolation for n-dimension. My PL has T[] type, dynamic array, where T — base type, T[][] — 2-dimensional, T[][][] — 3-dimensional, T[[]] — n-dimensional. Dynamic arrays is for memory allocation and garbage collection, though it's just freeing of dynamic sized local variables on function return.
My language has `each` construction for parallel programming, so same code can be executed on either CPU or GPU or other computational units. I'm going to add OpenCL to compiler when it will be prepared and rewrited to my PL.
resize2 — pixel 2-dimensional resizing function, no interpolation. There is `each` construction that defines instructions for each x in range(0,width) if pythonic or 0:width if my PL, and y in 0:height.
I see multiCPU and, maybe GPU paralleling, but SIMD and it's a problem.

Nanonymous No.3750 [D] >>3765

>>3701
You should at least attain feature parity with Julia.
https://github.com/JuliaMath

Nanonymous No.3765 [D]

>>3750
stfu nigger

Nanonymous No.3772 [D]

Your programming language is retarded. Ask yourself :
- How is my language different?
- What use case does it fit?
- Is it worth the time investment?
- Would anybody be interested?
- Is another language not already close enough? Can't I contribute to or fork that one?

Nanonymous No.3773 [D] >>3776

My programming language is beautiful.
My language is very different to other PLs.
General-purpose programmings, MCU programming, parallel and claster computation, neural networks.
YES.
Maybe.
No, I can't.

Nanonymous No.3776 [D]

>>3773
Wew, you really convinced me, I'm sold.

Nanonymous No.3784 [D]

he isn't trying to sell you anything nigger go back to reddit

Nanonymous No.3785 [D]

>>3766
Though you are right in 4th punkt. I would fork a C compiler and customize to my mind. Now I'm writing on python with pyparsing and llvmlite and it's a hell. Pyparsing is totally slow thing, written whole in python and it have bugs xor I'm using it wrong.
llvmlite pip-installed version don't support named struct type representation, only `literal` struct types so my LLVM asm looks like:
define void @"inscom.main.0"({i3, {{{i8, i16, i16, {i1, i1, i1, i61, i8*}, i8*}, {i1, i1, i1, i61, i8*}, {i8, i16, i16, {i1, i1, i1, i61, i8*}, i8*}*}, i64, i8*}}* %".1", i1 %".2", ...)
{
.4:
%"a" = alloca {i8*, {i1, i1, i1, i61, i8*}}
%".5" = getelementptr {i8*, {i1, i1, i1, i61, i8*}}, {i8*, {i1, i1, i1, i61, i8*}}* %"a", i32 0, i32 0
%".6" = zext i32 4 to i64
%".7" = mul i64 1, %".6"
%".8" = call i8* @"malloc"(i64 %".7")
store i8* %".8", i8** %".5"
%".10" = getelementptr {i8*, {i1, i1, i1, i61, i8*}}, {i8*, {i1, i1, i1, i61, i8*}}* %"a", i32 0, i32 1
%".11" = alloca {i1, i1, i1, i61, i8*}
store {i1, i1, i1, i61, i8*} zeroinitializer, {i1, i1, i1, i61, i8*}* %".11"
%".13" = getelementptr {i1, i1, i1, i61, i8*}, {i1, i1, i1, i61, i8*}* %".11", i32 0, i32 3
%".14" = zext i32 4 to i61
store i61 %".14", i61* %".13"
%".16" = load {i1, i1, i1, i61, i8*}, {i1, i1, i1, i61, i8*}* %".11"
store {i1, i1, i1, i61, i8*} %".16", {i1, i1, i1, i61, i8*}* %".10"
br i1 %".2", label %".19", label %".18"
.18:
%".21" = getelementptr inbounds {i3, {{{i8, i16, i16, {i1, i1, i1, i61, i8*}, i8*}, {i1, i1, i1, i61, i8*}, {i8, i16, i16, {i1, i1, i1, i61, i8*}, i8*}*}, i64, i8*}}, {i3, {{{i8, i16, i16, {i1, i1, i1, i61, i8*}, i8*}, {i1, i1, i1, i61, i8*}, {i8, i16, i16, {i1, i1, i1, i61, i8*}, i8*}*}, i64, i8*}}* %".1", i32 0, i32 0
store i3 1, i3* %".21"
%".23" = getelementptr inbounds {i3, {{{i8, i16, i16, {i1, i1, i1, i61, i8*}, i8*}, {i1, i1, i1, i61, i8*}, {i8, i16, i16, {i1, i1, i1, i61, i8*}, i8*}*}, i64, i8*}}, {i3, {{{i8, i16, i16, {i1, i1, i1, i61, i8*}, i8*}, {i1, i1, i1, i61, i8*}, {i8, i16, i16, {i1, i1, i1, i61, i8*}, i8*}*}, i64, i8*}}* %".1", i32 0, i32 1, i32 1
%".24" = zext i32 0 to i64
store i64 %".24", i64* %".23"
br label %".19"
.19:
ret void
}
But it's too late.
I want make a compiller, dapa library and llvm binding to make normal compiler. Compiler-interpreter. Not interpreter of code but interpreter of code file, like ELF interpreter in Linux.

Nanonymous No.3786 [D]

Problem:
float have infinity accuracy and it's rational number. In my PL is power operator . Okay if power is integer, but fractional number.
If it's 25
0.5, it's also okay, but 2**0.5, which irrational number. int, uN, sN, f/rNeM has finite accuracy, so for this it's okay and power can be any rational number.
I can raise exception for float when power is fractional, but I want throw exception only if shall be irrational number. Maybe it's bad idea.
How to detect if power makes irrational number?