Numerical Thingy from book to code, Calculus, Physics and allthat - (mainly) written in C, Python and other language i locked my eyes into.
I decide to learn C by solving Calculus and Physics problem found in any book, mainly from what i got in class(es) as undergrad. Geophysics student
So please bare with the MeEsSy C code. Also a disclaimer, i will make a bunch of typo, it is just me bad at typing, i'm working on it.
source:
NOTE: The source currently in private mode, i'll make the public one ASAP
- i need to:
- Learn C
- Being able to integrate C and my mother language Python as she's being so slow for some reason.
- it is just fun to learn new language, especially when you was so traumatized by C++ back then.
- also some bash scripting to make life more easy.
- As i implicityly said before, i'm coming from python, so the c codes written would be smelled like a snake :)
here's how i write the code
- Read some book
- look up for the problems
- try to solve it using pencil and papers
- code the problem and solution in C
- ofc compile and check the results
- write a wrapper for python
all of the code that are written in C and Zig are located in source/
directory. per 28/12/2014, i've wrote these:
Dec 27 21:55 area_within_interval.c
Dec 27 21:54 area_within_interval.h
Dec 28 04:05 area_within_interval.zig
Dec 27 22:59 example_area_within_interval.c
Dec 28 02:00 function_as_parameter.zig
Dec 27 20:51 problem_set_4_1.c
Dec 27 21:36 problemsetA_13_21.c
most of c codes above were my initial attempt on learning C throught calculus material i learned in Uni.
The zig code area_within_interval.zig is my first attempt to re-write the area_within_interval.c and [area_within_interval.h] in Zig.
i'm on Windows, here's the prereqs.:
-
im using gcc from StrawberryPerl 5.40 but i'm pretty sure y'all can use gcc from MINGW or Cygwin or clang too.
-
im using python 3.10
-
python dependency, install it using y'all fav package manager.
-
The python code are wrapped by the cffi
from either directly from c scripts and headers, or from the
shared objects.
The build_source.sh
will compile the C scripts to executables located in bins/
sub-dir
and shared objects (later for python usage) located in shared_objects/
sub-dir
The script also empties the bins/
and shared_objects
before produces new executables and shared objects.
from root directory, make the bash script build_source.sh
executable.
chmod u+x build_source.sh
NOTE: for now, i just use script instead of make/cmake, but let see where it will get me to
then, just run the build_source.sh
by run one of the following command on y'all shell
$ ./build_source.sh
$ .\build_source.sh
bash build_source.sh
from root directory just zig run source/zig_script.zig
All of python codes are wrapped by the cffi
and separated in modules based on the problem
from specified materials located in materials/non_codings/
sub-dir
see main.py
for example. y'all can play with it.
run the main.py as a regular python script:
python main.py # if you on Windows
python3 main.py # if you on MacOS or Linux