summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt5
-rw-r--r--test.cc18
-rw-r--r--zp/include/zp/det/mem.ii12
-rw-r--r--zp/include/zp/mem14
-rw-r--r--zp/include/zp/mth14
5 files changed, 44 insertions, 19 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index cbc7aec..1524ff6 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -7,6 +7,11 @@
* Make cpy, equ, fil, and srh run-time and throwable;
* Bring back opt;
+* Add move constructor for arr;
+* Add method to arr for getting the underlying pointer;
+* Add copy constructor for arr;
+* Add method for checking if the arr is okay;
+
# 1.0.0
* Update API-BREAK file;
diff --git a/test.cc b/test.cc
index 5f625af..d31c83f 100644
--- a/test.cc
+++ b/test.cc
@@ -307,18 +307,18 @@ int main() {
tst("mathematics");
}();
- /*[&] {
+ [&] {
tst("vectors");
- ::zp::vec2<int> const lvec2 = {
- .x = +0x1,
- .y = -0x3,
+ /* ::zp::vec2<int> const lvec2 = {
+ +0x1,
+ -0x3,
};
::zp::vec2<int> const rvec2 = {
- .x = +0x2,
- .y = -0x4,
+ +0x2,
+ -0x4,
};
- chkeq(::zp::dot(lvec2,rvec2),0xE);
+ chkeq(::zp::dot2(lvec2,rvec2),0xE);
::zp::vec3<int> const lvec3 = {
.x = +0x1,
@@ -351,8 +351,8 @@ int main() {
chkeq(avec2.x,+0x3);
chkeq(avec2.y,-0x7);
chkeq(svec2.x,-0x1);
- chkeq(svec2.y,+0x1);
- }();*/
+ chkeq(svec2.y,+0x1);*/
+ }();
[&] {
tst("memory sequences");
diff --git a/zp/include/zp/det/mem.ii b/zp/include/zp/det/mem.ii
index ce1a522..02aca0e 100644
--- a/zp/include/zp/det/mem.ii
+++ b/zp/include/zp/det/mem.ii
@@ -6,13 +6,25 @@
template<typename typ,typename alctyp> zp::arr<typ,alctyp>::arr() : _alc(alctyp()) {}
+template<typename typ,typename alctyp> zp::arr<typ,alctyp>::arr(::zp::arr<typ,alctyp> & oth) : _alc(alctyp()),_buf(this->_alc.allocate(len)),_len(oth._len) {
+ zp_unlik (this->_buf == zp_nulptr) {return;} // Allocation failed.
+
+ ::zp::cpy(this->_buf,oth._buf,oth._len);
+}
+
template<typename typ,typename alctyp> zp::arr<typ,alctyp>::arr(::zp::siz const len) : _alc(alctyp()),_buf(this->_alc.allocate(len)),_len(len) {}
+#if zp_std_cxx11
+template<typename typ,typename alctyp> zp::arr<typ,alctyp>::arr(::zp::arr<typ,alctyp> && oth) : _alc(oth._alc),_buf(oth._buf),_len(oth._len) {oth._buf = zp_nulptr;}
+#endif
+
template<typename typ,typename alctyp> zp_nothw zp::arr<typ,alctyp>::~arr() {
zp_unlik (this->_buf == zp_nulptr) {return;}
this->_alc.deallocate(this->_buf,this->_len);
}
+template<typename typ,typename alctyp> zp_nothw bool zp::arr<typ,alctyp>::oky() const {return this->_buf == zp_nulptr;}
+
template<typename typ,typename alctyp> zp_nothw ::zp::siz zp::arr<typ,alctyp>::len() const {return this->_len;}
template<typename typ,typename alctyp> bool zp::arr<typ,alctyp>::alc(::zp::siz const len) {
diff --git a/zp/include/zp/mem b/zp/include/zp/mem
index da45e84..d486773 100644
--- a/zp/include/zp/mem
+++ b/zp/include/zp/mem
@@ -18,12 +18,20 @@ namespace zp {
template<typename typ,typename alctyp> class arr {
public:
- arr();
- explicit arr(::zp::siz len);
+ zp_nothw arr();
+ arr(::zp::arr<typ,alctyp> & oth);
+ explicit arr(::zp::siz len);
+#if zp_std_cxx11
+ zp_nothw arr(::zp::arr<typ,alctyp> && oth);
+#endif
zp_nothw ~arr();
- zp_nothw ::zp::siz len() const;
+ zp_nothw bool oky() const;
+
+ zp_nothw typ * ptr();
+ zp_nothw typ const* ptr() const;
+ zp_nothw ::zp::siz len() const;
bool alc(::zp::siz len);
diff --git a/zp/include/zp/mth b/zp/include/zp/mth
index 4122a47..8cd815a 100644
--- a/zp/include/zp/mth
+++ b/zp/include/zp/mth
@@ -11,7 +11,7 @@
#include <zp/mth.h>
namespace zp {
- template<typename typ> struct divmodres {
+ template<typename typ> class divmodres {
typ lval;
typ rval;
};
@@ -82,14 +82,14 @@ namespace zp {
zp_iln zp_nothw zp_unseq zp_useres inline ::zp::divmodres<i02s> divmod(::zp::i02s num,::zp::i02s den);
zp_iln zp_nothw zp_unseq zp_useres inline ::zp::divmodres<i04s> divmod(::zp::i04s num,::zp::i04s den);
- zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f02 dot2(::zp::vec2< ::zp::f02> lvec,::zp::vec2< ::zp::f02> rvec);
- zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f04 dot2(::zp::vec2< ::zp::f04> lvec,::zp::vec2< ::zp::f04> rvec);
+ zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f02 dot2(::zp::vec2< ::zp::f02> const& lvec,::zp::vec2< ::zp::f02> const& rvec);
+ zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f04 dot2(::zp::vec2< ::zp::f04> const& lvec,::zp::vec2< ::zp::f04> const& rvec);
- zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f02 dot3(::zp::vec3< ::zp::f02> lvec,::zp::vec3< ::zp::f02> rvec);
- zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f04 dot3(::zp::vec3< ::zp::f04> lvec,::zp::vec3< ::zp::f04> rvec);
+ zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f02 dot3(::zp::vec3< ::zp::f02> const& lvec,::zp::vec3< ::zp::f02> const& rvec);
+ zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f04 dot3(::zp::vec3< ::zp::f04> const& lvec,::zp::vec3< ::zp::f04> const& rvec);
- zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f02 dot4(::zp::vec4< ::zp::f02> lvec,::zp::vec4< ::zp::f02> rvec);
- zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f04 dot4(::zp::vec4< ::zp::f04> lvec,::zp::vec4< ::zp::f04> rvec);
+ zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f02 dot4(::zp::vec4< ::zp::f02> const& lvec,::zp::vec4< ::zp::f02> const& rvec);
+ zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f04 dot4(::zp::vec4< ::zp::f04> const& lvec,::zp::vec4< ::zp::f04> const& rvec);
zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f02 exp(::zp::f02 val,::zp::f02 n);
zp_iln zp_nothw zp_unseq zp_useres inline ::zp::f04 exp(::zp::f04 val,::zp::f04 n);