引用库更新

This commit is contained in:
iridiumR 2022-03-12 12:50:04 +08:00
parent de11c25836
commit 765165c153
2 changed files with 30 additions and 12 deletions

View file

@ -2,7 +2,7 @@
* @Author: iR * @Author: iR
* @Date: 2022-03-11 16:44:46 * @Date: 2022-03-11 16:44:46
* @LastEditors: iR * @LastEditors: iR
* @LastEditTime: 2022-03-12 12:30:44 * @LastEditTime: 2022-03-12 12:49:04
* @FilePath: \Code\inc\matrix.hpp * @FilePath: \Code\inc\matrix.hpp
* @Description: * @Description:
* *
@ -86,7 +86,23 @@ public:
* @param {int} h * @param {int} h
* @return {*} * @return {*}
*/ */
T &at(int w, int h) { return _mat[h * _width + w]; } T &at(int w, int h)
{
double &ref = _mat->get(h * _width + w);
return ref;
}
/**
* @description: 访
* @param {int} w
* @param {int} h
* @return {*}
*/
const T &at(int w, int h) const
{
double &ref = _mat->get(h * _width + w);
return ref;
}
const int getWidth() const { return _width; } const int getWidth() const { return _width; }
const int getHeight() const { return _height; } const int getHeight() const { return _height; }

View file

@ -2,7 +2,7 @@
* @Author: iR * @Author: iR
* @Date: 2022-03-11 16:47:31 * @Date: 2022-03-11 16:47:31
* @LastEditors: iR * @LastEditors: iR
* @LastEditTime: 2022-03-12 12:20:35 * @LastEditTime: 2022-03-12 12:49:25
* @FilePath: \Code\inc\vector.hpp * @FilePath: \Code\inc\vector.hpp
* @Description: * @Description:
* *
@ -43,7 +43,7 @@ public:
~Vector() { delete[] _v; } ~Vector() { delete[] _v; }
//获取值 //获取值
T get(int a) const; T &get(int a);
//操作符重载 //操作符重载
T &operator[](int i); T &operator[](int i);
@ -109,7 +109,7 @@ Vector<T>::Vector(int len, T value)
} }
template <class T> template <class T>
T Vector<T>::get(int a) const T &Vector<T>::get(int a)
{ {
try try
@ -124,7 +124,6 @@ T Vector<T>::get(int a) const
catch (const char *msg) catch (const char *msg)
{ {
std::cout << msg; std::cout << msg;
return 0;
} }
} }
@ -134,7 +133,10 @@ T& Vector<T>::operator[](int a)
try try
{ {
if (a >= 0 && a < _used) if (a >= 0 && a < _used)
return _v[a]; {
T &ref = _v[a];
return ref;
}
else else
throw "Error: Request vercor data out of range!\n"; throw "Error: Request vercor data out of range!\n";
} }