Hello Jerry W,
Find here a C++ program that I wrote based on the information in your posting.
14 Dec 2016 - v0.0.1
For matrix/array problems of this type, I recommend using Boost multi_array: http://www.boost.org/doc/libs/1_62_0/libs/multi_array/doc/
http://www.boost.org/doc/libs/1_62_0/libs/multi_array/doc/user.html
On Mac/Linux/UNIX compile with: g++ -std=c++11 TDFDcube.cpp -o TDFDcube
NOTE: You must have Boost installed!