#] #] ********************* #] loaddefs link d_MindCode 'data types.ndf' # www.BillHowell.ca 29Mar2020 split off 'MindCode basics.ndf' # view this file in a text editor, with [constant width font, tab = 3 spaces] # see also "MindCode/5_MindCode global variable explanations.txt" # [simple, common] data types are defined here # [complex, special] data types are typially defined in [neuron, cluster] definition files f_types := 'data types.ndf' ; loaddefs_start f_types ; #] #]******************************************************* #] List of typedefs from all MindCode .ndfs # $ grep "^#]" "$d_Qndfs""MindCode/data types.ndf" | sed 's/^#\]/ /' #***************************************************** #] MindCode data types - see # # $ grep -r "^typedef " "$d_Qndfs""MindCode/" | sed 's|/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/MindCode/||' #------------------ data types.ndf:typedef "int_8bit ( 8 reshape o) ; data types.ndf:typedef "int_32bit (32 reshape o) ; #08********08 #] +-----+ #] [simple, common] data types are defined here IF flag_debug THEN write '+-----+' ; ENDIF ; IF flag_debug THEN write '[simple, common] data types are defined here' ; ENDIF ; typedef "int_8bit ( 8 reshape o) ; typedef "int_32bit (32 reshape o) ; #08********08 #] +-----+ #] [simple, common] data types are defined here # 14Mar2020 To run multiple MindCodes simulataneously - run separate instances of QNial in different terminals IF flag_debug THEN write '+-----+' ; ENDIF ; IF flag_debug THEN write '[simple, common] data types are defined here' ; ENDIF ; IF flag_debug THEN write 'loading setup_8bit' ; ENDIF ; #] setup_8bit IS - currently 8 neuron spike patterns (8 bits = byte, signed) setup_8bit IS { NONLOCAL intg_loww intg_high real_loww real_high realBase_max bitCnt_intgBase bits_sign bits_base bits_expt bitCnt_sign bitCnt_base bitCnt_expt realCode ; % ; % for integers - sign base ; bitCnt_intgBase := 7 ; % ; % for reals - sign base expt ; bits_sign := 0 ; bits_base := 1 2 3 4 5 ; bits_expt := 6 7 ; bitCnt_sign := gage shape bits_sign ; bitCnt_base := gage shape bits_base ; bitCnt_expt := gage shape bits_expt ; realCode := bits_sign bits_base bits_expt ; intg_loww := -127 ; intg_high := 127 ; real_loww := -31000. ; real_high := 31000. ; realBase_max := 31 ; % reals have < 2-digit accuracy! ; } setup_8bit ; # ISSUE : how many bits to include? # biogically, 8-bits may be unreasonable? # practically, low precision severely limits utility of # reminder - Z80 requires 8 neuron spike pattern, 1 bit sign, 5 bit base, 2 bit expt, -31000. <= intg <= 31000.) # this gives less than two-digit accuracy!! (1/30) # 03Apr2020 this isn't enough in practice - gives wild round-off errors # how about using 2-byte (16 bit) reals? This way, some degree of precision is available to test MindCode # on practical problems? # integers - 8- signed is -127 to +127 (pretty rough) # provide enough range for reals to at least accomodate 127*127 = 16129 # 03Apr2020 Decision : go with IEEE 32-bit signed single precision? # That's equivalent to assuming arrays of neurons to do the job! # makes it practical # see https://en.wikipedia.org/wiki/Single-precision_floating-point_format # high bit 31 - sign # upper bits 30-23 - exponent ( 8 bits) # lower bits 22-00 - fraction (23 bits) # note that I can select one or the other, depending on application (bio or engineering) IF flag_debug THEN write 'loading setup_32bit' ; ENDIF ; #] setup_32bit IS - 8 neuron spike patterns (8 bits = byte, signed) # oops - integer overflow with QNial setup_32bit IS { NONLOCAL intg_loww intg_high real_loww real_high realBase_max bitCnt_intgBase bits_sign bits_base bits_expt bitCnt_sign bitCnt_base bitCnt_expt realCode ; % ; % for integers - sign base ; bitCnt_intgBase := 7 ; % ; % for reals - sign base expt ; bits_sign := 0 ; bits_base := tell 23 ; bits_expt := 23 + tell 8 ; bitCnt_sign := gage shape bits_sign ; bitCnt_base := gage shape bits_base ; bitCnt_expt := gage shape bits_expt ; realCode := bits_sign bits_base bits_expt ; intg_loww := -2147483647 ; intg_high := 2147483647 ; real_loww := -31000. ; % wikipedia : (2 − 2^−23) × 2^127 ≈ 3.4028235 × 10^38 real_high := 31000. ; realBase_max := 31 ; % reals have < 2-digit accuracy! ; } setup_32bit ; # real_high : (2. − (2 power −23)) * (2 power 127) ≈ 3.4028235 × 10^38 # 2147483647 * 5 write 'loading : ' #08********08 #] +-----+ #] power_series IS OP bitWidth - produce a power series for conversion of bits to [intg, real, etc] # 23Feb2020 base 2 (binary) as suited to spikes IF flag_debug THEN write '+-----+' ; ENDIF ; IF flag_debug THEN write 'power_series' ; ENDIF ; IF flag_debug THEN write 'loading power_series' ; ENDIF ; #] power_series IS - currently 8 neuron spike patterns (8 bits = byte, signed) power_series IS OP bitWidth { 2 EACHRIGHT power (reverse tell bitWidth) } loaddefs_ended f_types ; # enddoc