CategoryProgramming

The problem of “Beautiful Arrays” with C Source code

An array is called beautiful if for every pair of numbers , , (), there exists an  such that . Note that can be equal to or too. Input First line of the input contains an integer T denoting the number of test cases. T test cases follow. First line of each test case contains an integer n denoting number of elements in a. Next line contains n space separated integers denoting the array a. Output...

Find the Elapsed Time using Monotonic Clocks in Linux

When a linux program requires measuring elapsed time, you need an individual timer to perform this task. This timer should be independent even if the user changes the time on the system clock. In Linux there are several different implementations for different cases (): CLOCK_REALTIMESystem-wide realtime clock. Setting this clock requires appropriate privileges.CLOCK_MONOTONICClock that cannot be...

Edge detection with a given direction using Matlab

The aim of this article is to detect the edges with a given direction in an image. To that end create a function [ E ] = oriented_edges( I, thr, a, da ) that takes as input a double grayscale image Ι, a threshold value thr, a direction a, and an angle da. The output of the function is a binary image Ε where the pixels that meet the following requirements should have the value 1: The pixel...

C++ Template Class for Linear Algebra Matrix

It seems that many projects come upon a need to perform some linear algebra maths. However, the a large number of the available libraries usually are huge with many unnecessary or system dependent functionalities or …they are not free. The following template class provides some basic linear algebra matrix operations such as +,-,* as well as find the determinant, the covariance matrix...

CRC16 Simple Algorithm for C

The following code snippet is about CRC16 hash function. Usually in embedded systems there is an already built-in function for CRC8-16-32 etc. However in case there is not, here is a simple approach for it. If you are looking for CRC8 Algorithm please go to the following post here. /* CRC_H_ */ #ifndef CRC_H_ #define CRC_H_ #ifdef __cplusplus extern "C" { #endif #include <string.h> #include...

Improved circular list /array (ring buffer) in C++

This is a new version of the ring buffer. Using function templates the FIFO ring buffer is able to handle almost any type of data. template<typename T> struct cbuffer_t { T * data; T * first; T * next; int max; }; template<typename T> extern cbuffer_t<T> * cBufferInit(int); template<typename T> extern int cBufferPush(cbuffer_t<T> *, T ); template<typename T> extern int...

Simple Memory Management

This project is a memory allocation scheme that provides efficient dynamic memory allocation for small embedded systems lacking a Memory Management Unit (MMU). The proposed Simple Memory Management Scheme (SMM) maintains a balance between performance and efficiency, with the objective to increase the amount of usable memory in MMU-less embedded systems with a bounded and acceptable timing...

Implement a circular list /array (ring buffer) in C

A very simple implementation, expressed in C. Implements a simple circular buffer in C as a FIFO queue. Note that this allows queues of any size. #ifndef CIRCULARBUFFER_H_ #define CIRCULARBUFFER_H_ typedef struct { int * data; int * first; int * next; int max; } cbuffer_t; cbuffer_t * cBufferInit(int max); int cBufferPush(cbuffer_t *c, int data); int cBufferPop(cbuffer_t *c, int *data); #endif /*...

C# Universal Applications – Local Settings

At the point when pondering your universal applications information, one angle to consider is data lifetime. All in all, with regards to the lifetime of information, you have two alternatives: local data, which exists as long as the app that created it remains installed, and roaming data. Use settings to store application state and client inclinations. The Universal Windows Platform (UWP) gives...

Windows 10 Hamburger menu for Universal Apps

Hamburger menu/button is a simple navigation design which we can see in most modern app platforms. In most of the default Windows 10 apps Microsoft has used this navigation pattern and also recommends it to the developers. I have found a lot of information about building such a feature in an app. Getting Started with the SplitView Control in Universal Apps Implementing an Awesome...

Disclaimer: The present content may not be used for training artificial intelligence or machine learning algorithms. All other uses, including search, entertainment, and commercial use, are permitted.

Categories

Tags