radicalite is a library written in C for elemental Fractions, Radicals, and Polynomials.
Make sure you have git installed. If not, you can download it from the official website or use a package manager.
Then execute the following command:
git clone https://codeberg.org/maxchen32/radicalite.git
to get the source code,
cd radicalite
to enter the source code directory.
Make sure you have GCC installed. If not, Windows users are recommended to use this precompiled GCC, and Linux users can install it through the distribution's package manager.
It is recommended to use xmake, but we also provide support for CMake.
xmake f --m release
xmakeIf you are using MinGW on windows, the first line should be written as:
xmake f --m release --toolchain=mingw
If you want to install into the system (default is /usr/local/lib):
xmake install --adminIf you want to compile the example program:
xmake -amkdir build
cd build
cmake ..
cmake --build .If you want to install into the system (default is /usr/local/lib):
sudo cmake --install .In this tutorial, we will write a program that calculates the product of
Create a file named test.c and open it.
Write the following code:
#include <stdio.h>
#include "radical.h"Initialize a variable a of type Radical to
Radical a = initRad(1, 2, 3);The three parameters of initRad(1, 2, 3) represent the numerator, denominator, and radicand.
Declare another variable b :
Radical a = initRad(1, 2, 3);
Radical b = initRad(4, 5, 6);Calculate the product of a and b and assign it to c :
Radical c = mulRad(a, b);Output c and a newline character to the console:
printRad(c);
putchar('\n');printRad(c) prints a variable of type Radical to the console, but does not add a newline.
#include <stdio.h>
#include "radical.h"
int main() {
Radical a = initRad(1, 2, 3);
Radical b = initRad(4, 5, 6);
Radical c = mulRad(a, b);
printRad(c);
putchar('\n');
return 0;
}If you have already installed the library, it's very simple:
gcc test.c -o test -lradical -lm
./testIf you are using MinGW on Windows:
gcc test.c -o test.exe -Ipath\to\radicalite\include -Lpath\to\radicalite\build\windows\x64\release -lradical
test.exeI don't have experience with MSVC at the moment, so I can't provide the corresponding method.
If everything goes well, it should output:
(6/5)√(2)
which is the correct result.