Generic class libraries for 1D array and 2D array: Array and Matrix. 1次元および2次元配列用の汎用クラスライブラリ: Array と Matrix.

Dependents:   F746_SD_WavPlayer CW_Decoder_using_FFT_on_F446 F446_MySoundMachine F446_ADF_Nlms ... more

Files at this revision

API Documentation at this revision

Comitter:
MikamiUitOpen
Date:
Sat Dec 19 08:22:52 2020 +0000
Parent:
3:d9dea7748b27
Commit message:
5

Changed in this revision

Array.hpp Show annotated file Show diff for this revision Revisions of this file
Matrix.hpp Show annotated file Show diff for this revision Revisions of this file
diff -r d9dea7748b27 -r d3aa1ddb57e1 Array.hpp
--- a/Array.hpp	Tue Nov 19 05:44:54 2019 +0000
+++ b/Array.hpp	Sat Dec 19 08:22:52 2020 +0000
@@ -3,7 +3,7 @@
 //      Macro definition "DEBUG_ARRAY_CHECK" enables to check
 //      range of index.
 //
-//  2019/11/19, Copyright (c) 2019 MIKAMI, Naoki
+//  2020/12/19, Copyright (c) 2020 MIKAMI, Naoki
 //-----------------------------------------------------------------------
 
 #include "mbed.h"
@@ -19,7 +19,7 @@
     public:
         explicit Array(int n = 1) { ArrayNew(n); }  // default constructor
         Array(const Array<T>& a) { Copy(a); }       // copy constructor
-        Array(int n, T initialValue);               // constructor with initialization
+        Array(int n, T initialVal);                 // constructor with initialization
         Array(int n, const T val[]);                // constructor with assignment built-in array
         ~Array() { delete[] v_; }                   // destructor
         void Fill(T val);                           // fill with same value
@@ -46,12 +46,12 @@
 //-----------------------------------------------------------------------
 
     // constructor with initialization
-    template <class T> inline Array<T>::Array(int n, T initialValue)
+    template <class T> inline Array<T>::Array(int n, T initialVal)
     {
         ArrayNew(n);
-        Fill(initialValue);
+        Fill(initialVal);
     }
-                                     
+
     // constructor with assignment built-in array
     template <class T> inline Array<T>::Array(int n, const T val[])
     {
@@ -68,14 +68,14 @@
     // fill with same value
     template <class T> inline void Array<T>::Fill(T val)
     {
-        for (int n=0; n<size_; n++) v_[n] = val;        
+        for (int n=0; n<size_; n++) v_[n] = val;
     }
 
     // assign built-in array
     template <class T> inline void Array<T>::Assign(const T val[])
     {
-        for (int n=0; n<size_; n++) v_[n] = val[n];        
-    }          
+        for (int n=0; n<size_; n++) v_[n] = val[n];
+    }
 
     template <class T> inline Array<T>& Array<T>::operator=(const Array<T>& a)
     {
diff -r d9dea7748b27 -r d3aa1ddb57e1 Matrix.hpp
--- a/Matrix.hpp	Tue Nov 19 05:44:54 2019 +0000
+++ b/Matrix.hpp	Sat Dec 19 08:22:52 2020 +0000
@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 //  Generic 2-dimensional array class ---- Matrix
 //
-//  2016/05/22, Copyright (c) 2016 MIKAMI, Naoki
+//  2020/12/19, Copyright (c) 2020 MIKAMI, Naoki
 //------------------------------------------------------------------------------
 
 #ifndef MIKAMI_MATRIX_HPP
@@ -15,11 +15,11 @@
     {
     public:
         explicit Matrix(int rows = 1, int cols = 1);
-        Matrix(int rows, int cols, T initialValue);
+        Matrix(int rows, int cols, T initialVal);
         void Fill(T val);
         void SetSize(int rows, int cols);                           // setting size
         Array<T>& operator[](int i) { return vv_[i]; }              // assign by element
-        const Array<T>& operator[](int i) const { return vv_[i]; }  //get element
+        const Array<T>& operator[](int i) const { return vv_[i]; }  // get element
         int Rows() const { return vv_.Length(); }
         int Cols() const { return vv_[0].Length(); }
     private:
@@ -35,10 +35,10 @@
         for (int i=0; i<rows; i++) vv_[i] = a;
     }
 
-    template <class T> Matrix<T>::Matrix(int rows, int cols, T initialValue)
+    template <class T> Matrix<T>::Matrix(int rows, int cols, T initialVal)
             : vv_(rows)
     {
-        Array<T> a(cols, initialValue);
+        Array<T> a(cols, initialVal);
         for (int i=0; i<rows; i++) vv_[i] = a;
     }
 
@@ -54,5 +54,4 @@
         for (int i=0; i<rows; i++) vv_[i] = a;
     }
 }
-#endif  // MIKAMI_MATRIX_HPP
-
+#endif  // MIKAMI_MATRIX_HPP
\ No newline at end of file