C Programming Language¶
Learning C¶
- The best way to learn programming is, always, writing your own code!
- Why Code in C Anymore?….Instead of
C++
- C still has a little advantage on the performance and portability.
- CS2022: Introduction to C at
Cornell
- Lecture slides are available.
- learn-c.org free interactive C tutorial
- 30-seconds-of-c
- Curated collection of useful C Programming tutorials, snippets, and projects that you can understand in 30 seconds or less
Useful Libraries¶
Performance¶
- Optimization of Computer Programs in
C
- By Michael Lee. “It focuses on minimizing time spent by the CPU and gives sample source code transformations that often yield improvements. Memory and I/O speed improvements are also discussed.”
- Tips for Optimizing C/C++
Code
- Very practical and useful guides for optimizing C/C++.
- mimalloc - mimalloc is a compact general purpose allocator with
excellent performance
- By Microsoft. mimalloc (pronounced “me-malloc”) is a general purpose allocator with excellent performance characteristics. It is a drop-in replacement for malloc and can be used in other programs without code changes.
Numerical¶
- GSL - GNU Scientific Library
- The library provides a wide range of mathematical routines such as random number generators, special functions and least-squares fitting. There are over 1000 functions in total with an extensive test suite.
- The online reference manual can be found here.
- FFTW
- FFTW is a C subroutine library for computing the discrete Fourier transform (DFT) in one or more dimensions, of arbitrary input size, and of both real and complex data (as well as of even/odd data, i.e. the discrete cosine/sine transforms or DCT/DST).
- The online manual can be found here
Code to Study¶
- sextractor - Extract catalogs of sources from astronomical images
- psfex - Generate PSF super-tabulated models
- CCL - DESC Core Cosmology
Library
- Also teaches you how to interact with Python.
- Corrfunc - fast correlation functions on the
CPU
- utils are written in C; and wrapped in Python.
On Interacting with Python¶
- sep - Python and C library for source extraction and
photometry
- Using Cython.
- cosmology - Some code for calculating cosmological
distances
- By Erin Sheldon. Using CPython
- smatch - Code to match points on the sphere using the healpix
scheme
- By Erin Sheldon. Using CPython