mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.1 SparseArray
This commit is contained in:
parent
b40ad81a76
commit
afa34b1215
@ -1,3 +1,18 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
@ -9,5 +24,6 @@ compile:
|
||||
- esp32
|
||||
- esp8266
|
||||
# - mega2560
|
||||
- rpipico
|
||||
libraries:
|
||||
- "SHT85"
|
17
libraries/SparseArray/CHANGELOG.md
Normal file
17
libraries/SparseArray/CHANGELOG.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Change Log sparseArray
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.1.1] - 2022-11-25
|
||||
- Add RP2040 support to build-CI.
|
||||
- Add CHANGELOG.md
|
||||
- update readme.md
|
||||
|
||||
|
||||
## [0.1.0] - 2022-07-17
|
||||
- initial version, derives from SparseMatrix
|
||||
|
@ -11,22 +11,20 @@
|
||||
Arduino library for sparse arrays of floats.
|
||||
|
||||
|
||||
TODO REDO DOCUMENTATION.
|
||||
|
||||
|
||||
## Description
|
||||
|
||||
SparseArray is an **experimental** library to implement a one
|
||||
dimensional sparse array of floats (a.k.a. vector) on an Arduino.
|
||||
A sparse array is a mn array with mostly zeros and a low percentage
|
||||
A sparse array is an array with mostly zeros and a low percentage
|
||||
non-zero values.
|
||||
The purpose of this library is efficient storage in memory.
|
||||
|
||||
The maximum array that can be represented is 65535 elements
|
||||
The maximum array size this library can represent is 65535 elements
|
||||
with a theoretical maximum of 65535 non-zero elements.
|
||||
(although that does not make sense due to overhead)
|
||||
In practice the library limits this to 1000 non-zero elements.
|
||||
Note: 255 elements would still fit in an UNO's 2K memory.
|
||||
In practice the library limits the number of non-zero elements to 1000.
|
||||
|
||||
Note: 255 non-zero elements would fit in an UNO's 2K memory.
|
||||
|
||||
Relates to:
|
||||
- https://github.com/RobTillaart/SparseMatrix
|
||||
@ -40,12 +38,14 @@ Note: this library is derived from SparseMatrix.
|
||||
The implementation is based on 2 arrays holding ```x, value```
|
||||
where value is float, and x is an uint16_t.
|
||||
That are 6 bytes per element.
|
||||
The number of elements that the sparse array object can hold are
|
||||
The number of elements that the sparse array object can hold is
|
||||
given as parameter to the constructor.
|
||||
If the space cannot be allocated the size is set to zero.
|
||||
|
||||
In the future other data types should be possible.
|
||||
|
||||
Relates to https://github.com/RobTillaart/SET
|
||||
|
||||
|
||||
#### Performance
|
||||
|
||||
@ -99,10 +99,19 @@ This can be useful for printing or processing the non zero elements.
|
||||
|
||||
## Future
|
||||
|
||||
- documentation
|
||||
- test
|
||||
#### must
|
||||
- improve documentation
|
||||
|
||||
#### should
|
||||
- do test
|
||||
- investigate optimizations
|
||||
- derived sorted class ==> insertSort
|
||||
- keep in sync with SparseMatrix where possible
|
||||
- merge into one class hierarchy?
|
||||
- Template class for the data type
|
||||
- better than SparseArray64 SparseArray32 SparseArray16 SparseArray8 (signed / unsigned?)
|
||||
|
||||
#### could
|
||||
- dump should be in the class?
|
||||
- or as static function...
|
||||
- stream as param dump(Stream str, ...
|
||||
@ -112,5 +121,7 @@ This can be useful for printing or processing the non zero elements.
|
||||
- array { uint32_t, float }; for logging millis/micros + measurement
|
||||
delta coding of time stamp? if it fit in 16 bit?
|
||||
=> sounds like a class on its own.
|
||||
- investigate index \[\] operator for **get()** and **set()**
|
||||
- would break with sparse matrix
|
||||
|
||||
|
||||
|
@ -1,15 +1,10 @@
|
||||
//
|
||||
// FILE: SparseArray.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// VERSION: 0.1.1
|
||||
// DATE: 2022-07-17
|
||||
// PURPOSE: Arduino library for sparse arrays of floats
|
||||
// URL: https://github.com/RobTillaart/SparseArray
|
||||
//
|
||||
// HISTORY:
|
||||
// 0.1.0 2022-07-17 initial version
|
||||
// derives from SparseMatrix
|
||||
|
||||
|
||||
|
||||
#include "SparseArray.h"
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: SparseArray.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// VERSION: 0.1.1
|
||||
// DATE: 2022-07-17
|
||||
// PURPOSE: Arduino library for sparse arrays of floats
|
||||
// URL: https://github.com/RobTillaart/SparseArray
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
#define SPARSEARRAY_LIB_VERSION (F("0.1.0"))
|
||||
#define SPARSEARRAY_LIB_VERSION (F("0.1.1"))
|
||||
|
||||
#ifndef SPARSEARRAY_MAX_SIZE
|
||||
#define SPARSEARRAY_MAX_SIZE 1000
|
||||
@ -31,9 +31,8 @@ public:
|
||||
|
||||
|
||||
// returns false if no slots free
|
||||
// could return # free slots?
|
||||
bool set(uint16_t x, float value);
|
||||
// adds value to element x,y
|
||||
// adds value to element x
|
||||
bool add(uint16_t x, float value);
|
||||
float get(uint16_t x);
|
||||
|
||||
@ -42,18 +41,18 @@ public:
|
||||
void boundingSegment(uint16_t &minX, uint16_t &maxX);
|
||||
|
||||
|
||||
private:
|
||||
protected:
|
||||
uint16_t _size = 0;
|
||||
uint16_t _count = 0;
|
||||
|
||||
uint16_t *_x = NULL; // support array's [0..65535]
|
||||
float *_value = NULL;
|
||||
|
||||
// returns index of x, y if in set
|
||||
// returns index of x if in set
|
||||
// otherwise -1
|
||||
int32_t findPos(uint16_t x);
|
||||
|
||||
// removes element at pos (from findPos)
|
||||
// removes element at position (from findPos)
|
||||
// pre: count > 0
|
||||
void removeElement(uint16_t pos);
|
||||
// creates a new element if value != 0 and if there is room
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/SparseArray.git"
|
||||
},
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=SparseArray
|
||||
version=0.1.0
|
||||
version=0.1.1
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for sparse arrays of floats.
|
||||
|
Loading…
Reference in New Issue
Block a user