yet more additions

This commit is contained in:
madrocketsci
2025-05-12 16:59:21 -04:00
parent 94060cee88
commit 8f5774695f
8 changed files with 33 additions and 3 deletions

View File

@ -1,3 +1,9 @@
# amscppperm1
Numeric array template class library. A numeric array, in addition to the usual array operations, is expected to have numeric data that can be added, subtracted, multiplied, etc.
Numeric array template class library. A numeric array, in addition to the usual array operations, is expected to have numeric data that can be added, subtracted, multiplied, etc.
This numeric array class implements random number generation, threaded vector operations, threaded math and statistics for fast operations on the arrays.
The primary object is the template class narray<T>
ams::narray::narray<T>

Binary file not shown.

View File

@ -53,6 +53,8 @@ template<typename T> class narray
narray<T>& operator=(const std::initializer_list<T> initlist);
~narray();
template<typename T2> operator narray<T2>() const; //casting datatypes
int resize(const narray_size_t newlength);
const narray_size_t size() const;

View File

@ -225,6 +225,28 @@ template<typename T> narray<T>& narray<T>::operator=(const std::initializer_list
return *this;
}
template<class T> template<class T2> narray<T>::operator narray<T2>() const
{
//casting datatypes
narray<T2> ret;
int res;
res = ret.resize(this->length);
if(res!=narray_success)
{
ret.resize(0);
return ret;
}
else
{
buffer_copycast<T2,T>(&(ret.data),data,length);
}
return ret;
}
template<typename T> narray<T>::~narray()
{
//printf("debug: destructor called for %p\n",this);

View File

@ -63,7 +63,7 @@ namespace narray
printf("rseed: %d\n",(int)rand::dpr32_rseed); //< -- this is different than the line above
narray<double> unif = ams::narray::rand::narray_rand(100);
narray<double> unif = ams::narray::rand::narray_rand(10000*10000);
printf("rseed: %d\n",(int)rand::get_rseed());

View File

@ -9,7 +9,7 @@ int main(int argc, char* argv[])
// ams::narray::test_narray3();
// ams::narray::narray_testmath1();
ams::narray::narray_testmath2();
ams::narray::narray_testmath3();
//ams::narray::narray_testmath3();
return ret;
}