diff --git a/build/__pycache__/amsbuildlib4.cpython-311.pyc b/build/__pycache__/amsbuildlib4.cpython-311.pyc new file mode 100644 index 0000000..c9e0813 Binary files /dev/null and b/build/__pycache__/amsbuildlib4.cpython-311.pyc differ diff --git a/build/make.linux64.test.py b/build/make.linux64.test.py index 7fef03e..5fa106f 100644 --- a/build/make.linux64.test.py +++ b/build/make.linux64.test.py @@ -14,7 +14,7 @@ depdir = "./dependencies/linux64" #local pre-compiled dependency libraries and t installdir = "../../linux64" #directory to install to when finished builddir = "./build_linux64" -doinstall = False #copies the build_output to the install dir when finished +doinstall = True #copies the build_output to the install dir when finished cc = "g++" #compiler cflags = "-O3 -fPIC" libraries = "-l{}".format(libname) diff --git a/build_linux64/libamsmathutil25.linux64.a b/build_linux64/libamsmathutil25.linux64.a index 7e9c8aa..e0936f3 100644 Binary files a/build_linux64/libamsmathutil25.linux64.a and b/build_linux64/libamsmathutil25.linux64.a differ diff --git a/build_linux64/objstore/amsmathtuil25_test1.o b/build_linux64/objstore/amsmathtuil25_test1.o index 48c656d..40c3d92 100644 Binary files a/build_linux64/objstore/amsmathtuil25_test1.o and b/build_linux64/objstore/amsmathtuil25_test1.o differ diff --git a/build_linux64/tests b/build_linux64/tests index eb01714..1b1d8d6 100644 Binary files a/build_linux64/tests and b/build_linux64/tests differ diff --git a/build_mingw64/libamsmathutil25.mingw64.a b/build_mingw64/libamsmathutil25.mingw64.a index faa83ce..60503aa 100644 Binary files a/build_mingw64/libamsmathutil25.mingw64.a and b/build_mingw64/libamsmathutil25.mingw64.a differ diff --git a/build_mingw64/objstore/amscpptemplate25a_src2.o b/build_mingw64/objstore/amscpptemplate25a_src2.o index 6150531..61ce3f0 100644 Binary files a/build_mingw64/objstore/amscpptemplate25a_src2.o and b/build_mingw64/objstore/amscpptemplate25a_src2.o differ diff --git a/build_mingw64/objstore/amscpptemplate25a_template.o b/build_mingw64/objstore/amscpptemplate25a_template.o index 4fc396d..657abaf 100644 Binary files a/build_mingw64/objstore/amscpptemplate25a_template.o and b/build_mingw64/objstore/amscpptemplate25a_template.o differ diff --git a/build_mingw64/objstore/amsmathtuil25_test1.o b/build_mingw64/objstore/amsmathtuil25_test1.o index d4ec942..2d15e7f 100644 Binary files a/build_mingw64/objstore/amsmathtuil25_test1.o and b/build_mingw64/objstore/amsmathtuil25_test1.o differ diff --git a/build_mingw64/objstore/amsmathutiil25_random.o b/build_mingw64/objstore/amsmathutiil25_random.o index 25e958b..c9a5c91 100644 Binary files a/build_mingw64/objstore/amsmathutiil25_random.o and b/build_mingw64/objstore/amsmathutiil25_random.o differ diff --git a/build_mingw64/objstore/amsmathutil25_amsarray.o b/build_mingw64/objstore/amsmathutil25_amsarray.o index 909bd8d..cf9e892 100644 Binary files a/build_mingw64/objstore/amsmathutil25_amsarray.o and b/build_mingw64/objstore/amsmathutil25_amsarray.o differ diff --git a/build_mingw64/objstore/amsmathutil25_amsarray_sort.o b/build_mingw64/objstore/amsmathutil25_amsarray_sort.o index 2cee879..d1bb318 100644 Binary files a/build_mingw64/objstore/amsmathutil25_amsarray_sort.o and b/build_mingw64/objstore/amsmathutil25_amsarray_sort.o differ diff --git a/build_mingw64/objstore/amsmathutil25_mathfns1.o b/build_mingw64/objstore/amsmathutil25_mathfns1.o index 27dc603..ba7f185 100644 Binary files a/build_mingw64/objstore/amsmathutil25_mathfns1.o and b/build_mingw64/objstore/amsmathutil25_mathfns1.o differ diff --git a/build_mingw64/objstore/amsmathutil25_utils1.o b/build_mingw64/objstore/amsmathutil25_utils1.o index cbf7a14..9db8b45 100644 Binary files a/build_mingw64/objstore/amsmathutil25_utils1.o and b/build_mingw64/objstore/amsmathutil25_utils1.o differ diff --git a/build_mingw64/objstore/amsmathutil25_vec2.o b/build_mingw64/objstore/amsmathutil25_vec2.o index c707303..fa0bcdf 100644 Binary files a/build_mingw64/objstore/amsmathutil25_vec2.o and b/build_mingw64/objstore/amsmathutil25_vec2.o differ diff --git a/build_mingw64/objstore/amsmathutil25_vec2f.o b/build_mingw64/objstore/amsmathutil25_vec2f.o index 18bcfce..a3c84de 100644 Binary files a/build_mingw64/objstore/amsmathutil25_vec2f.o and b/build_mingw64/objstore/amsmathutil25_vec2f.o differ diff --git a/build_mingw64/objstore/amsmathutil25_vec3.o b/build_mingw64/objstore/amsmathutil25_vec3.o index 10391b7..abd3d30 100644 Binary files a/build_mingw64/objstore/amsmathutil25_vec3.o and b/build_mingw64/objstore/amsmathutil25_vec3.o differ diff --git a/build_mingw64/objstore/amsmathutil25_vec3f.o b/build_mingw64/objstore/amsmathutil25_vec3f.o index e268348..1802cd7 100644 Binary files a/build_mingw64/objstore/amsmathutil25_vec3f.o and b/build_mingw64/objstore/amsmathutil25_vec3f.o differ diff --git a/build_mingw64/objstore/amsmathutil25_vec4.o b/build_mingw64/objstore/amsmathutil25_vec4.o index dad355c..b0c18be 100644 Binary files a/build_mingw64/objstore/amsmathutil25_vec4.o and b/build_mingw64/objstore/amsmathutil25_vec4.o differ diff --git a/build_mingw64/objstore/amsmathutil25_vec4f.o b/build_mingw64/objstore/amsmathutil25_vec4f.o index d0959b6..dca1f44 100644 Binary files a/build_mingw64/objstore/amsmathutil25_vec4f.o and b/build_mingw64/objstore/amsmathutil25_vec4f.o differ diff --git a/build_mingw64/objstore/amsmathutil2t_complex128.o b/build_mingw64/objstore/amsmathutil2t_complex128.o index 4db4a6b..2d4704a 100644 Binary files a/build_mingw64/objstore/amsmathutil2t_complex128.o and b/build_mingw64/objstore/amsmathutil2t_complex128.o differ diff --git a/build_mingw64/objstore/amsmathutil2t_complex64.o b/build_mingw64/objstore/amsmathutil2t_complex64.o index 2f26e27..9230797 100644 Binary files a/build_mingw64/objstore/amsmathutil2t_complex64.o and b/build_mingw64/objstore/amsmathutil2t_complex64.o differ diff --git a/build_mingw64/tests.exe b/build_mingw64/tests.exe index 165f964..64bb173 100644 Binary files a/build_mingw64/tests.exe and b/build_mingw64/tests.exe differ diff --git a/include/amsmathutil25/testing/amsmathutil25_testing.hpp b/include/amsmathutil25/testing/amsmathutil25_testing.hpp index 0b0dacf..2412f7c 100644 --- a/include/amsmathutil25/testing/amsmathutil25_testing.hpp +++ b/include/amsmathutil25/testing/amsmathutil25_testing.hpp @@ -14,6 +14,7 @@ namespace amsmathutil25 void test_amsarray_insertdelete1(); void test_amsarray_insertdelete2(); void test_amsarray_minimal(); + void test_amsarray_arrayinsert(); diff --git a/include/amsmathutil25/util/amsmathutil25_amsarray.hpp b/include/amsmathutil25/util/amsmathutil25_amsarray.hpp index e95ce52..74f8b91 100644 --- a/include/amsmathutil25/util/amsmathutil25_amsarray.hpp +++ b/include/amsmathutil25/util/amsmathutil25_amsarray.hpp @@ -79,6 +79,10 @@ namespace ams T pop_back(); T pop_front(); + int insert(amsarray_size_t ind, const amsarray& other); + int append(const amsarray& other); + + //finds the first instance of val in the array amsarray_size_t find(const T& val); diff --git a/include/amsmathutil25/util/amsmathutil25_amsarray_impl.hpp b/include/amsmathutil25/util/amsmathutil25_amsarray_impl.hpp index e7d7898..c2fcb73 100644 --- a/include/amsmathutil25/util/amsmathutil25_amsarray_impl.hpp +++ b/include/amsmathutil25/util/amsmathutil25_amsarray_impl.hpp @@ -470,6 +470,87 @@ template int amsarray::insert(amsarray_size_t ind, const T& val) return ret; } +template int amsarray::insert(amsarray_size_t ind, const amsarray& other) +{ + int ret = amsarray_success; + + int res; + amsarray_size_t I, oldlen; + amsarray_size_t I0,I1; + + if(other.length==0) + { + ret = amsarray_success; + return ret; + } + + if(ind<0) + { + ret = amsarray_failure; + return ret; + } + else if(ind<=this->length) + { + oldlen = this->length; + res = this->resize_insert(this->length + other.length); + if(res==amsarray_success) + { + //for now, do things single threaded. + //to do things multithreaded, I'd need another buffer + if(this->data!=NULL && other.data!=NULL) + { + for(I=oldlen;I>=ind+other.length;I--) + { + this->data[I] = this->data[I-1]; + } + for(I=ind;Idata[I] = other.data[I-ind]; + } + } + ret = amsarray_success; + return ret; + } + else + { + ret = amsarray_failure; + return ret; + } + } + else + { + //inserting past the end of the array + res = this->resize_insert(ind+other.length); + if(res!=amsarray_success) + { + ret = amsarray_failure; + return ret; + } + else + { + if(this->data !=NULL && other.data !=NULL) + { + for(I=ind;Idata[I] = other.data[I-ind]; + } + } + ret = amsarray_success; + return ret; + } + } + + return ret; +} + +template int amsarray::append(const amsarray &other) +{ + int ret = amsarray_success; + + ret = insert(length,other); + return ret; +} + //removes the value at index ind, and reduces array size by 1 template int amsarray::erase(amsarray_size_t ind) { diff --git a/include/amsmathutil25/util/amsmathutil25_util.hpp b/include/amsmathutil25/util/amsmathutil25_util.hpp index c70f2f3..393127d 100644 --- a/include/amsmathutil25/util/amsmathutil25_util.hpp +++ b/include/amsmathutil25/util/amsmathutil25_util.hpp @@ -9,6 +9,12 @@ namespace ams //psize must be supplied to determine whether to execute in threaded mode or not. template int threaded_execute(callable &&fptr, int64_t psize, argst&&... args); + +//A template function that takes as input a function pointer and a series of arguments +//The function is executed with fptr(threadnum, nthreads, otherargs...) with a given number of threads +template int numthreaded_execute(callable &&fptr, int nthreads, argst&&... args); + + template struct pair { public: diff --git a/include/amsmathutil25/util/amsmathutil25_utilimpl.hpp b/include/amsmathutil25/util/amsmathutil25_utilimpl.hpp index c9bcedf..8ade2bf 100644 --- a/include/amsmathutil25/util/amsmathutil25_utilimpl.hpp +++ b/include/amsmathutil25/util/amsmathutil25_utilimpl.hpp @@ -68,6 +68,56 @@ template int threaded_execute(callable && return ret; } +//A template function that takes as input a function pointer and a series of arguments +//The function is executed with fptr(threadnum, nthreads, otherargs...) with a given number of threads +template int numthreaded_execute(callable &&fptr, int nthreads, argst&&... args) +{ + int ret = amsmathutil25_success; + int I; + std::vector threads; + + if(nthreads<=1) + { + nthreads = 1; + I = 0; + fptr(I,nthreads,std::forward(args)...); + } + else + { + threads.resize(nthreads); + for(I=0;I(fptr), + I, + nthreads, + std::forward(args)... + ); + } + for(I=0;Ijoin(); + delete threads[I]; + threads[I] = NULL; + } + } + } + + return ret; +} + }; //end namespace ams diff --git a/src/amsmathutil25/testing/amsmathtuil25_test1.cpp b/src/amsmathutil25/testing/amsmathtuil25_test1.cpp index 56f64d4..2965702 100644 --- a/src/amsmathutil25/testing/amsmathtuil25_test1.cpp +++ b/src/amsmathutil25/testing/amsmathtuil25_test1.cpp @@ -293,7 +293,33 @@ void test_amsarray_minimal() } } +void test_amsarray_arrayinsert() +{ + amsarray q1,q2,q3; + int I; + q1 = {1,2,3,4,5}; + q2 = {0,0,1,0}; + + q3 = q1; + + printf("Array append test\n"); + printf("q3="); q3.print(1); + printf("q2="); q2.print(1); + q3.append(q2); + printf("q3+q2="); q3.print(1); + + printf("q3="); q3.print(1); + printf("q2="); q2.print(1); + for(I=-2;I