MyCaffe
1.12.2.41
Deep learning software for Windows C# programmers.
|
The Utility class provides general utility funtions. More...
Public Member Functions | |
Utility () | |
The Utility constructor. More... | |
Static Public Member Functions | |
static int | CanonicalAxisIndex (int nIdx, int nNumAxes) |
Returns the 'canonical' version of a (usually) user-specified axis, allowing for negative indexing (e.g., -1 for the last axis). More... | |
static int | GetSpatialDim (List< int > rg, int nStartIdx=0) |
Calculate the spatial dimension of an array starting at a given axis. More... | |
static int | Count (List< int > rgShape, int nStartIdx=0, int nEndIdx=-1) |
Return the count of items given the shape. More... | |
static int | Count (int[] rgShape, int nStartIdx=0, int nEndIdx=-1) |
Return the count of items given the shape. More... | |
static void | Save< T > (BinaryWriter bw, List< T > rg) |
Save a list of items to a binary writer. More... | |
static List< T > | Load< T > (BinaryReader br) |
Loads a list of items from a binary reader. More... | |
static void | Save (BinaryWriter bw, List< double > rg) |
Save a list of double to a binary writer. More... | |
static List< double > | LoadDouble (BinaryReader br) |
Loads a list of double from a binary reader. More... | |
static void | Save (BinaryWriter bw, List< float > rg) |
Save a list of float to a binary writer. More... | |
static List< float > | LoadFloat (BinaryReader br) |
Loads a list of float from a binary reader. More... | |
static void | Save (BinaryWriter bw, int? nVal) |
Saves a nullable int to a binary writer. More... | |
static ? int | LoadInt (BinaryReader br) |
Loads a nullable int from a binary reader. More... | |
static int | BaseTypeSize< T > () |
Returns the base type size, where double = 8, float = 4. More... | |
static double | ConvertVal< T > (T fVal) |
Convert a generic to a double. More... | |
static float | ConvertValF< T > (T fVal) |
Convert a generic to a float. More... | |
static T | ConvertVal< T > (double dfVal) |
Convert a double to a generic. More... | |
static double[] | ConvertVec< T > (T[] rg) |
Convert an array of generics to an array of double. More... | |
static float[] | ConvertVecF< T > (T[] rg, int nStart=0) |
Convert an array of generics to an array of float. More... | |
static T[] | ConvertVec< T > (double[] rgdf) |
Convert an array of double to an array of generics. More... | |
static T[] | ConvertVec< T > (float[] rgf) |
Convert an array of float to an array of generics. More... | |
static double[] | ConvertVec (float[] rgf) |
Convert an array of float to an array of generics. More... | |
static void | Resize< T > (ref List< T > rg, int nCount, T tDefault) |
Resize a List and fill the new elements with the default value. More... | |
static T[] | Clone< T > (T[] rg) |
Copy an array. More... | |
static List< T > | Clone< T > (List< T > rg, int nMaxCount=int.MaxValue) |
Copy a List up to a maximum count. More... | |
static List< T > | Clone< T > (T[] rg, int nMaxCount=int.MaxValue) |
Copy a List up to a maximum count. More... | |
static bool | Compare< T > (List< T > rg1, List< T > rg2, bool bExact=true) |
Compares one List to another. More... | |
static List< T > | Create< T > (int nCount, T fDefault) |
Create a new List and fill it with default values up to a given count. More... | |
static List< int > | Create (int nCount, int nStart, int nInc) |
Create a new List and fill it with values starting with start and incrementing by inc. More... | |
static void | Set< T > (List< T > rg, T fVal) |
Set all values of a List with a given value. More... | |
static void | Set< T > (T[] rg, T fVal) |
Set all values within an array with a given value. More... | |
static string | ToString< T > (List< T > rg, int nDecimals=-1, int nIdxHighight=-1, string strStart="{", string strEnd="}") |
Convert an array to a string. More... | |
static List< int > | ParseListToInt (string str) |
Parses a comma delimited string into an array of int. More... | |
static int | GetNumber (string str) |
Parses a string into a number, or if the string does not contain a number returns 0. More... | |
static string | Replace (string str, char ch1, char ch2) |
Replaces each instance of one character with another character in a given string. More... | |
static string | Replace (string str, char ch1, string str2) |
Replaces each instance of one character with another string in a given string. More... | |
static string | Replace (string str, string str1, char ch2) |
Replaces each instance of one character with another string in a given string. More... | |
static string | ReplaceMacro (string strRaw, string strMacroName, string strReplacement) |
The ConvertMacro method is used to replace a set of macros in a given string. More... | |
static string | ReplaceMacros (string strRaw, List< KeyValuePair< string, string > > rgMacros) |
The ReplaceMacros method is used to replace a set of macros in a given string. More... | |
static double | ConvertTimeToMinutes (DateTime dt) |
Convert a date time into minutes since 1/1/1980 More... | |
static DateTime | ConvertTimeFromMinutes (double dfMin) |
Convert a number of minutes into the date time equivalent to 1/1/1980 + the minutes. More... | |
static List< int > | RandomShuffle (List< int > rg, int? nSeed=null) |
Randomly shuffle the entries in the specified list. More... | |
static List< string > | LoadTextLines (string strFile, Log log=null, bool bPrependPath=true) |
Load each line of a text file and return the contents as a list. More... | |
The Utility class provides general utility funtions.
Definition at line 34 of file Utility.cs.
MyCaffe.basecode.Utility.Utility | ( | ) |
The Utility constructor.
Definition at line 39 of file Utility.cs.
|
static |
Returns the base type size, where double = 8, float = 4.
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
Definition at line 431 of file Utility.cs.
|
static |
Returns the 'canonical' version of a (usually) user-specified axis, allowing for negative indexing (e.g., -1 for the last axis).
nIdx | The axis index. |
nNumAxes | The total number of axes. |
Definition at line 50 of file Utility.cs.
|
static |
Copy a List up to a maximum count.
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
rg | Specifies the list to copy. |
nMaxCount | Optionally, specifies a maximum count to copy. |
Definition at line 605 of file Utility.cs.
|
static |
Copy an array.
T | Specifies the base type. |
rg | Specifies the source array. |
Definition at line 587 of file Utility.cs.
|
static |
Copy a List up to a maximum count.
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
rg | Specifies the array to copy. |
nMaxCount | Optionally, specifies a maximum count to copy. |
Definition at line 632 of file Utility.cs.
|
static |
Compares one List to another.
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
rg1 | Specifies the first List. |
rg2 | Specifies the second List. |
bExact | Optionally, specifies to look for an exact match. When false a trailing one is accepted if the count()'s match. |
Definition at line 657 of file Utility.cs.
|
static |
Convert a number of minutes into the date time equivalent to 1/1/1980 + the minutes.
dfMin | Specifies the minutes since 1/1/1980. |
Definition at line 1008 of file Utility.cs.
|
static |
Convert a date time into minutes since 1/1/1980
dt | Specifies the datetime to convert. |
Definition at line 996 of file Utility.cs.
|
static |
Convert a double to a generic.
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
dfVal | Specifies the double value. |
Definition at line 467 of file Utility.cs.
|
static |
Convert a generic to a double.
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
fVal | Specifies the generic value. |
Definition at line 445 of file Utility.cs.
|
static |
Convert a generic to a float.
T | Specifies the base type float or float. Using float is recommended to conserve GPU memory. |
fVal | Specifies the generic value. |
Definition at line 456 of file Utility.cs.
|
static |
Convert an array of float to an array of generics.
rgf | Specifies the array of float. |
Definition at line 550 of file Utility.cs.
|
static |
Convert an array of double to an array of generics.
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
rgdf | Specifies the array of double. |
Definition at line 513 of file Utility.cs.
|
static |
Convert an array of float to an array of generics.
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
rgf | Specifies the array of float. |
Definition at line 534 of file Utility.cs.
|
static |
Convert an array of generics to an array of double.
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
rg | Specifies the array of generics. |
Definition at line 478 of file Utility.cs.
|
static |
Convert an array of generics to an array of float.
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
rg | Specifies the array of generics. |
nStart | Specifies a start offset (default = 0). |
Definition at line 496 of file Utility.cs.
|
static |
Return the count of items given the shape.
rgShape | Specifies the shape to count from the start index through the end index. |
nStartIdx | Specifies the start index (default = 0). |
nEndIdx | Specifies the end index (default = -1, which uses length of rgShape). |
Definition at line 105 of file Utility.cs.
|
static |
Return the count of items given the shape.
rgShape | Specifies the shape to count from the start index through the end index. |
nStartIdx | Specifies the start index (default = 0). |
nEndIdx | Specifies the end index (default = -1, which uses length of rgShape). |
Definition at line 83 of file Utility.cs.
|
static |
Create a new List and fill it with values starting with start and incrementing by inc.
nCount | Specifies the number of items. |
nStart | Specifies the start value. |
nInc | Specifies the increment added to the last value added. |
Definition at line 721 of file Utility.cs.
|
static |
Create a new List and fill it with default values up to a given count.
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
nCount | Specifies the number of items. |
fDefault | Specifies the default value. |
Definition at line 702 of file Utility.cs.
|
static |
Parses a string into a number, or if the string does not contain a number returns 0.
str | Specifies the string to parse. |
Definition at line 837 of file Utility.cs.
|
static |
Calculate the spatial dimension of an array starting at a given axis.
rg | Specifies the shape to measure. |
nStartIdx | Specifies the starting axis. |
Definition at line 64 of file Utility.cs.
|
static |
Loads a list of items from a binary reader.
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
br | Specifies the binary reader. |
Definition at line 230 of file Utility.cs.
|
static |
Loads a list of double from a binary reader.
br | Specifies the binary reader. |
Definition at line 352 of file Utility.cs.
|
static |
Loads a list of float from a binary reader.
br | Specifies the binary reader. |
Definition at line 385 of file Utility.cs.
|
static |
Loads a nullable int from a binary reader.
br | Specifies the binary reader. |
Definition at line 416 of file Utility.cs.
|
static |
Load each line of a text file and return the contents as a list.
strFile | Specifies the text file to load. |
log | Optionally, specifies the output log used to output errors (default = null). When null, any errors are thrown as exceptions. |
bPrependPath | Optionallly, specifies to prepend the path of the 'strFile' to each file within the file, but only do so with entries starting with '.' |
Definition at line 1054 of file Utility.cs.
|
static |
Parses a comma delimited string into an array of int.
str | Specifies the string to parse. |
Definition at line 819 of file Utility.cs.
|
static |
Randomly shuffle the entries in the specified list.
rg | Specifies the input list to shuffle. |
nSeed | Optionally, specifies a seed for the random generator. |
Definition at line 1021 of file Utility.cs.
|
static |
Replaces each instance of one character with another character in a given string.
str | Specifies the string. |
ch1 | Specifies the character to find. |
ch2 | Specifies the character replacement. |
Definition at line 864 of file Utility.cs.
|
static |
Replaces each instance of one character with another string in a given string.
str | Specifies the string. |
ch1 | Specifies the character to find. |
str2 | Specifies the string replacement. |
Definition at line 889 of file Utility.cs.
|
static |
Replaces each instance of one character with another string in a given string.
str | Specifies the string. |
str1 | Specifies the string to find. |
ch2 | Specifies the char replacement. |
Definition at line 914 of file Utility.cs.
|
static |
The ConvertMacro
method is used to replace a set of macros in a given string.
strRaw | Specifies the raw string. |
strMacroName | Specifies the macro to be replaced. |
strReplacement | Specifies the replacement string. |
Definition at line 947 of file Utility.cs.
|
static |
The ReplaceMacros
method is used to replace a set of macros in a given string.
strRaw | Specifies the raw string. |
rgMacros | Specifies the set of macros. |
Definition at line 978 of file Utility.cs.
|
static |
Resize a List and fill the new elements with the default value.
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
rg | Specifies the List to resize. |
nCount | Specifies the new count. |
tDefault | Specifies the default value used when expanding the list. |
Definition at line 565 of file Utility.cs.
|
static |
Saves a nullable int to a binary writer.
bw | Specifies the binary writer. |
nVal | Specifies the value to write. |
Definition at line 403 of file Utility.cs.
|
static |
Save a list of double to a binary writer.
bw | Specifies the binary writer. |
rg | Specifies the list of items. |
Definition at line 337 of file Utility.cs.
|
static |
Save a list of float to a binary writer.
bw | Specifies the binary writer. |
rg | Specifies the list of items. |
Definition at line 370 of file Utility.cs.
|
static |
Save a list of items to a binary writer.
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
bw | Specifies the binary writer. |
rg | Specifies the list of items. |
Definition at line 126 of file Utility.cs.
|
static |
Set all values of a List with a given value.
T |
rg | Specifies the List. |
fVal | Specifies the value. |
Definition at line 741 of file Utility.cs.
|
static |
Set all values within an array with a given value.
T | Specifies the base type float or double. Using float is recommended to conserve GPU memory. |
rg | Specifies the array to set. |
fVal | Specifies the value. |
Definition at line 755 of file Utility.cs.
|
static |
Convert an array to a string.
T | Specifies the base type of the array. |
rg | Specifies the array. |
nDecimals | Optionally, specifies the number of decimals (default = -1, ignored) |
nIdxHighight | Optionally, specifies the index to highlight (default = -1, ignored) |
strStart | Optionally, specifies the start bracket (default = '{') |
strEnd | Optionally, specifies the end bracket (default = '}') |
Definition at line 773 of file Utility.cs.