LibCapy - Download

LibCapy is a C library I develop as a side project. Learn more about it here.

How to download and install LibCapy:

Download the latest version of the library with the following commands:

To download an older version of the library, replace libcapy.latest.tar.gz with the version's tar file (cf below).

Install the library by following instructions in INSTALL.md. The installation process and unit tests have been tested in the following environment (using Docker images or real machine): Ubuntu 16.04, Ubuntu 18.04, Ubuntu 20.04, Manjaro. If you encounter problems and need help, contact me. After installation the folder ~/LibCapy is not needed any more and you can delete it cd ~ && rm -r LibCapy. For examples of how you can use it and what you can do with it, refer to the LibCapy examples.

v0.8.0 (release preview at the end of 2024/03)

- CapyMath. Add CapyPowf.
- Generic trees and their iterator (breadth first, depth first).
- MemPool. Add size, nbUsed and sizeMax. Modif to let the user decide the name of the MemPool struct. Modif to allow the user to initialized the allocated memory.
- CapyMiniMax. Generic implementation of the minimax algorithm. Uses MemPool and sibling pruning.
- CapyRandom. Add Lemire's algorithm to generate faster integer within a range.
- CapyArray. Add shuffleLemire (shuffling using Fisher-Yate and Lemire).
- CapyX11Display. Add drawBezier.
- containerOf. Macro to get the address of a structure instance from the address of one of its field.
- CapyChrono. Add getTimeStamp (get the current time in yyyymmddhhiiss format).
- CapyLSystem. Generic implementation of L-Systems. Lindenmayer algae L-System.
- CapyPointCloud. Add updateStdDev, updatePearsonCorrelation.
- CapyTurtleGraphic. Logo's turtle graphics implementation.
- CapyDataset. Add handling of null/unknown values when loading a dataset.

- #29 Compilation options should be hardened as described in https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html
- #

v0.7.0 (released 2023/11/27)

tar file: libcapy.0.7.0.tar.gz

- CapyPointCloud. Add links property to use the point cloud as a graph.
- CapyPathFinder. A* algorithm on CapyPointCloud.
- CapyColor. Oklab colorspace (conversion from/to XYZ).
- CapyX11Display. Add methods setPixel, fillRectangle, drawLine, drawCircle, clear, reset on X11DisplayBuffer. Add type CapyX11RGB.
- CapyMath. Add CapyVec2DSetAngle, CapyVec2DGetAngle, CapyVecGetCosineSimilarity, CapyMatAddMat, CapyMatProdScalar.
- CapyGeomety2D. Replace CapyTriangleCorner, CapyQuadrilateralCorner, CapyCircleCenter with CapyPoint2D. Add CapySegment, CapyRectangle.
- CapyCollisionDetection. Test collision between point/circle, point/rectangle, circle/circle, rectangle/rectangle.
- CapyRandom. Add CapyGetTrulyRandomValue.
- CapyHashFun. Parent class for hash function classes.
- CapyFNV1aHashFun. FNV1a hash function.
- CapyDict. Refactor as a hash table. Add remove entry method. Remove prev method on iterators.
- CapyMathFun. Add EvalDivergence.
- CapyGraph. Add PageRank.
- CapyImgKernel. Add sharpen kernel and edge detection kernel.

- #28 In geometricShape, CapyTriangleCorner, CapyQuadrilateralCorner, CapyCircleCenter should all be a same 2d point structure.

v0.6.0 (released 2023/07/27)

tar file: libcapy.0.6.0.tar.gz

- CapyImg. Add saveToPath, CapyImgFromLoadFromPath.
- Cext. CapyChildProcEndsWithoutWait.
- CapyCombinator. Iterator on combination of indices.
- CapySampling. Parent class for all sampling algorithm.
- CapyPoissonSampling. Sampling according to the poisson distribution.
- CapyDFT2D. Discrete Fourier transform on images. Amplitude, phase, periodogram visualisation.
- CapyBresenham. Bresenham algorithm to iterate on 2D integer coordinates.
- CapyBezierIterator. Iterator allowing forEach(pos, ...) on CapyBezier of input dimension equal to 1.
- CapySdf. Signed distance function with constructive solid geometry.
- CapyQuaternion. Structure to manipulate 3D rotations using quaternions.

- #20 The following method and function should be added to the class CapyImg for convenience: CapyImg* CapyImgLoadFromPath)(char const* const path); void (*saveToPath)(char const* const path);
- #23 array.h: the Shuffle method for unsized array clobbered data by calculating improperly their adress during swapping.
- #19 missing unit tests for conversion of CapyDataset to CapyMat.
- #25 The iterator of a CapyImg is not initialised when using CapyImgCreate, leading to a crash when using $(img, destruct)() because img.iter.destruct is not initialised.
- #26 In CapyX11DisplayGetBuffer the wrong indice is used: CapyX11DisplayBuffer* buffer = that->buffers + that->outputBuffer; should be CapyX11DisplayBuffer* buffer = that->buffers + that->inputBuffer;

v0.5.0 (released 2023/03/18)

tar file: libcapy.0.5.0.tar.gz

- CapyPad. Macro to add fields with appropriately calculated size for explicit padding in structures.
- CapyAckley. Ackley's function implementation.
- CapyHimmelblau. Himmelblau's function implementation.
- CapyGradientDescent. Class implementing the gradient descent on a CapyMathFun object. Allow momentum and adaptive step.
- CapyBezierSpline. Composite of Bezier curves object.
- CapyCircle. 2D circle object. GetArea, getBezierSpline.
- CapyPen. DrawCircle, drawBezierSpline, drawGeometry2D. Refactor to use getBezierSpline on Triangle and Quadrilateral.
- CapyRandom. Replace xorshift64 with xorshift*64. Add PCG and set it as default algorithm instead of xorshift.
- CapyBezier. Replace CapyBezierCtrlIdx with uint16_t*.
- CapyGeometry2D. Parent class for CapyTriangle, CapyQuadrilateral, CapyCircle.
- CapyNeuralNetwork. Class implementing forward propagation neural network. Linear, step, sigmoid, hypertangent, relu, silu activation functions selectable per layer; multilayer; recurrent network supported.
- CapyDataset. Conversion to matrix for one hot encoding classifier.
- CapyNNClassifier. Multiclass classifier neural network. Training, prediction, export to C function.
- KfoldCrossValid. Load a predefined split.
- SlidingAverage. Class calculating a sliding average using O(1) memory.
- X11Display. Graphical display based on X11 and multithread.
- Polynomial1D. 1 dimension polynomial.
- DFT. Discrete Fourier Transform. Transform and inverse transform for 1 dimension polynomials of power-of-2 degree. Fourier series coefficients of a function for a given interval. Approximation of the function from the Fourier series coefficients.
- SupportVectorMachine. Export to HTML.
- DiffEvo. Add initialisation mode: random, or randomised seed. Add evolution mode: standard, or sequential with stride (instead of mutated values choosen randomly).
- Chrono. Get elapsed time with automatic selection of the most convenient unit.
- CapyMath. Test inclusion of a position in an ellipse. CapyCubicBezierEval; CapySmootherStep; CapyLerpNorm2Arr.
- CapyNoise. Parent class for all noise generator.
- CapyBNoise. Generate 2D noise using the B-Noise algorithm.

- #17 The function gettimeofday is obsolescent and should be replaced with clock_gettime in CapyChrono.
- #18 Automatic padding may induce bug when using `union{T v[...];struct{T a,b,...};};`. Should add -Wpadded to compilation argument and resolve all these warnings.
- #12 All XXXDestruct functions should be methods to deallocate memory correctly in the context of inheritance.
- #21 CapyPen.drawBezier and CapyPen.drawBezierSpline crash if the curve/spline has a dimOut>2.

v0.4.0 (released 2022/11/24)

tar file: libcapy.0.4.0.tar.gz

- CapyMath. 3D static vector; 3x3 static matrix; Conversion degrees/radians; Fast inverse square root; Solve quadratic/cubic/quartic equations; Fibonacci sequence, grid/polar lattice, sphere/demi-sphere lattice; Vector norm and normalisation; CapyMatCreateRotMat; CapyVec3DGetOrtho; PieceWiseGaussian; Approximated norm of a 2D vector.
- MathFun. Add domains property to allow the user to specify the domain of each input.
- Dataset. Add cvtToMatForSingleCatClassifier, getValueAsNormalisedNum methods.
- SupportVectorMachine. Support vector machine binary classifier. Train on a given dataset; Predict a given input.
- Classifier. Parent class for all classifiers. Evaluate the classifier (overall accuracy, confusion matrix).
- DiffEvo. Refactor to be multithreaded instead of multiprocessed; Refactor to take into account the domain of the fitness function; Add an optional constraint function.
- MemPool. Generic memory pool class. Alloc, free and flush elements of a given type.
- KfoldCrossValid. K-fold cross validation framework. Evaluate a CapyClassifier on a dataset.

- #11 The flag G_APPLICATION_FLAGS_NONE is deprecated and must be replaced with G_APPLICATION_DEFAULT_FLAGS when creating a GTK application.
- #13 All unit tests should be refactored using Cutest.
- #15 A silent mode for CapyArgParser should be added for cleaner unit tests.
- #16 The static analysis was performed with Cppcheck 1.90. The newer version 2.9 is detecting many problems left undetected by the older version. Cppcheck should be updated and the remaining problems should be corrected.

v0.3.0 (released 2022/07/25)

tar file: libcapy.0.3.0.tar.gz

- Comparator. Object to compare data (for example to sort them).
- Generic arrays. QSort.
- Sorting algorithms. QuickSort.
- CapyDistributionContinuous. Generic class to implement probability distribution for continuous random variables.
- CapyNormalDistribution.
- CapyImgKernel. Kernels for image processing. GaussianBlur; DerivativeGaussianBlur.
- CapyImg. Conversion to greyscale, black/white, hsv, normalised rgb, l1l2l3, c1c2c3, L*a*b*, conversion from L*a*b*; Add slope direction in edge map detection, and input channel used for detection; Cleanup function to ensure pixel values are in [0,1]; Set all three channels to the value of one of them in each pixel; Get the neighbour of a pixel; Get an edge map made of the combination of the edge map on each channel, choosing the maximum slope amongs them for each pixel.
- CapyColorPatch.Set of CapyImgPixel. Get the average color; Get the bounding quadrilateral; Get the center of mass.
- CapyColorChart. Add QP203 color chart L*a*b* data; Conversion ColorChart from RGB to L*a*b*; Split brightness in two versions for RGB and L*a*b*; Get similarity value between two charts; Automatically locate a chart in an image; Add X-Rite ColorChecker classic color chart.
- ColorPatch. Index of min/max on arrays of basic types.
- CapyColorSpace. Enumeration to identify color spaces.
- CapyFloodFill.
- CapyTriangle. Get area.
- CapyQuadrilateral. Get area.
- CapyMathFun. Get derivative; Get Jacobian.
- CapyVec. Refactor of CapyVector as a structure. Addition; Substraction; Multiplication; Cross product; Dot produt.
- CapyMat. Matrix data structure. Multiplication (with matrix and vector); Transpose; Inverse and pseudo inverse; Determinant.
- CapyIsAccessibleMem. Check if an adress is in the current accessible address space.
- CapyGraph. Object to manipulate graphs. Add node; Add link; Get connectivity matrix; Get distance matrix (in number of link).
- CapyPowMod. Calculate (a^b)%c using the square and multiply algorithm.
- Chrono. Class to measure elapsed time.
- Automatic code style checking and HTML/PDF doc generation.
- DatasetClass to manipulate datasets saved as CSV file with a descriptive header containing each field, label, type (numerical/categorical) and interface (input/output).
- Bezier. Save/Load to binary stream; Export as ready-to-use C function.
- PointCloud. Class to manipulate point cloud. Load from PLY file (ascii format only); Approximate with a Bezier surface.
- CapyColorCorrBezier. Color correction using Bezier surface; calculation of the Bezier surface matching to color chart; application of the Bezier surface to an image; load/save to a file.
- CapyColorCorr. Parent class color correction classes.
- CapyGreedy. Class implementing the Greedy algorithm.
- I/O Stream. Get file size.
- Math. QR decomposition; Eigen values and vectors.
- FileFormat. Virtual class for all the file format decoder/encoder implementations.
- PngFormat. Class to manipulate file in PNG format. Load/save an image.
- PlyFormat. Class to manipulate file in PLY format. Load/save a point cloud (ascii format).
- KMeans. Class implementing the k-means algorithm. Calculate the clusters best-fitting a point cloud (random, Forgy, plus plus); Get the cluster for a given point.
- DistributionDiscrete. Array of discrete events (pair of id/probability).
- Random. Get a random discrete event.
- FrequentistHypothesisTesting. Class implementing the frequentist hypothesis testing method.

- #9 The conversion of -0.3 to a CapyRatio fails.
- #10 safeMalloc fails if the `size` argument is not a single item (ex: safeMalloc(a, 3 + n))

v0.2.0 (released 2022/03/14)

tar file: libcapy.0.2.0.tar.gz

- Math functions: greatest common divisor using Stein's algorithm; Russian peasant multiplication of positive integers to calculate a*b and a*b/c; smooth step function with controllable slope; power function for integer variables; LERP.
- CapyRandom: pseudo random generator based on 64 bits xorshift, squirrel3 and the Downey's algorithm. Generation of integer, rational and real numbers within an interval.
- CapyElo: function to compute the ELO rank.
- ArgParser: Modif the return type of getAsInt() from int16_t to int64_t
- StreamIO: Add the methods isOpened(), readBytes(), writeBytes()
- Dict: dictionaries with char* key and generic value. Iterators on the dictionaries' entries.
- Ratio: rational number implementation. Addition, negation, substraction, multiplication, inverse, division, absolute value, comparison, reduction, conversion from/to double, raising to an integer power, square root.
- Image. Set the color of a pixel; create a clone; copy an image into anoher; change the gamma encoding; find the brightest pixel.
- Generic arrays. Shuffle.
- loopRange (shortcut of `for` loop on a CapyRange).
- MathFun. Abstract class to be inherited by other objects implementing mathematical functions.
- Bezier. Bezier curve/surface of any order/nb input/nb output.
- Pen. Tool to draw point and CapyBezier on a CapyImg. Color, hardness, size; draw point, line, Bezier.
- Display. Change the window's display during execution; get time in milliseconds since shown; handlers for onShow and onClose events; magnify to fit in an image; interaction via the mouse.
- CapyColorChart. Color chart for image color correction; QP203 color chart data; extraction of a color chart from an image; brightness matching between two charts; load/save to a file.
- CapyColorCorrMat. Color correction matrix; calculation of the matrix matching to color chart; application of the correction matrix to an image; load/save to a file.
- CapyColorHisto. Color histograms. Extract the histograms from an image; apply the histogram to an image.
- CapyDiffEvo. Optimizer using the differential evolution method. Run in a separate process.

- #1 Invalid free at the end of CapyDisplay.show() when the display has been created with CapyDisplayCreate()
- #2 The size of the generic arrays when reallocating is improperly calculated (sizeof(type) missing)
- #3 The size of the allocation in CapyDisplayMagnifierAlloc is erroneous
- #4 Remove the functions CapyVec*Add()
- #5 CapyArr.getPtr return the wrong adress. Multiplication by the size of data is missing
- #6 `loop` doesn't accept `const` variable as `nbIter` argument
- #7 The shared memory segments in CapyDisplay are never deallocated

v0.1.0 (released 2021/11/27)

tar file: libcapy.0.1.0.tar.gz

- Standard functions extended with exception management: safeMalloc, safeRealloc, safeFOpen, safeSPrintf, safeFPrintf, safeFScanf, safeFRead, safeFWrite
- min/max on arrays of basic types
- loop (shortcut of `for` loop) and forEach (iteration using iterators defined by LibCapy)
- println/fprintln (printf/fprintf with a line return)
- $ and $$ (operator for OOP methods)
- CapyInherits macro for class inheritance)
- equal (equality operator on floating point values using the ULP method)
- CapyGetVersion, CapyGetCommitId, CapyGetBuildMode (infos about the library)
- Exception management framework.
- Color, RGB/RGBA/HSV/greyscale modes. Conversion between RGB and HSV.
- Decoration of output to the CLI using escape sequences.
- Generic arrays, fixed size and resizable. Iterators (forward/backward) on these generic arrays.
- Generic double linked lists. Iterators (forward/backward) on these generic lists.
- PNG image, load/save, access/edit pixels. Iterator on the pixels.
- Display in a GTK window of an image in a separate process. Interaction via keyboard. Automatic refresh of the window content when the image is edited.
- Command line arguments parser.
- I/O Stream, load and save a text file content line by line, load and save the content of a file all at once.
- Feistel cipher network, available operation modes are ECB, CBC, CTR.
- Vector, vector of double values for numeric calculation, generic definition for any size, functions: add
- Range, range of numerical value; functions: trim
- CapySleepMs: sleep function accepting millisecond as argument