mirror of
https://github.com/triqs/dft_tools
synced 2024-12-25 13:53:40 +01:00
arrays: remove .len (redundant)
.len -> .shape with same syntax. Made a few necessary corrections here and there.
This commit is contained in:
parent
17a741ad9e
commit
6fa737978e
@ -137,8 +137,8 @@ struct foreach_manual_simple {
|
||||
const int u[2] = {1,0}; //=1, u1=0;
|
||||
//int u[2]; for (int i=0; i<2; ++i) u[i] = 1-i;
|
||||
for (int k =0; k<5000; ++k)
|
||||
for (t[u[0]]=0; t[u[0]]<A.len(u[0]); ++t[u[0]])
|
||||
for (t[u[1]] =0; t[u[1]]<A.len(u[1]); ++t[u[1]])
|
||||
for (t[u[0]]=0; t[u[0]]<A.shape(u[0]); ++t[u[0]])
|
||||
for (t[u[1]] =0; t[u[1]]<A.shape(u[1]); ++t[u[1]])
|
||||
A(t[u[1]],t[u[0]]) = 1876;
|
||||
//A[t] = 1876;
|
||||
}
|
||||
|
@ -137,8 +137,8 @@ struct foreach_manual_simple {
|
||||
const int u[2] = {1,0}; //=1, u1=0;
|
||||
//int u[2]; for (int i=0; i<2; ++i) u[i] = 1-i;
|
||||
for (int k =0; k<5000; ++k)
|
||||
for (t[u[0]]=0; t[u[0]]<A.len(u[0]); ++t[u[0]])
|
||||
for (t[u[1]] =0; t[u[1]]<A.len(u[1]); ++t[u[1]])
|
||||
for (t[u[0]]=0; t[u[0]]<A.shape(u[0]); ++t[u[0]])
|
||||
for (t[u[1]] =0; t[u[1]]<A.shape(u[1]); ++t[u[1]])
|
||||
A(t[u[1]],t[u[0]]) = 1876;
|
||||
//A[t] = 1876;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
test<vector<double> , vector<int> >();
|
||||
|
||||
// does not work for array just because of .size() vs .len(0)...
|
||||
// does not work for array just because of .size() vs .shape(0)...
|
||||
//test<array<double,1> , array<int,1> >();
|
||||
//test<array<double,1> , vector<int> >();
|
||||
//test<vector<double> , array<int,1> >();
|
||||
|
@ -49,7 +49,7 @@ namespace triqs { namespace arrays { namespace blas {
|
||||
D(range(0,s)) = d;
|
||||
E(range(0,s-1)) = e;
|
||||
int info;
|
||||
f77::stev ('V',d.size(),D.data_start(),E.data_start(), Z.data_start(), Z.len(0),W.data_start(), info);
|
||||
f77::stev ('V',d.size(),D.data_start(),E.data_start(), Z.data_start(), Z.shape(0),W.data_start(), info);
|
||||
if (info !=0) TRIQS_RUNTIME_ERROR << " Error in tridiagonal matrix diagonalization "<< info;
|
||||
}
|
||||
arrays::vector_view<double> values() const { return D(range(0,s));}
|
||||
|
@ -166,8 +166,6 @@ namespace triqs { namespace arrays {
|
||||
|
||||
size_t shape(size_t i) const { return domain().lengths()[i];}
|
||||
|
||||
size_t len(size_t i) const { return this->shape()[i]; }
|
||||
|
||||
size_t num_elements() const { return domain().number_of_elements();}
|
||||
|
||||
//bool is_empty() const { return this->num_elements()==0;}
|
||||
|
@ -44,9 +44,9 @@ namespace triqs { namespace arrays {
|
||||
|
||||
matrix_view<T> view(size_t i) const { return a(i,range(),range());}
|
||||
|
||||
size_t size() const { return a.len(0);}
|
||||
size_t dim0() const { return a.len(1);}
|
||||
size_t dim1() const { return a.len(2);}
|
||||
size_t size() const { return a.shape(0);}
|
||||
size_t dim0() const { return a.shape(1);}
|
||||
size_t dim1() const { return a.shape(2);}
|
||||
|
||||
matrix_stack_view & operator +=(matrix_stack_view const & arg) { a += arg.a; return *this; }
|
||||
matrix_stack_view & operator -=(matrix_stack_view const & arg) { a -= arg.a; return *this; }
|
||||
|
@ -34,7 +34,7 @@ namespace triqs { namespace arrays {
|
||||
// to do : separate the array and the matrix case.
|
||||
// generalize with preprocessor (draft below)
|
||||
|
||||
// write concept mutable down and clean it (dim0, dim1, len(i), ...)
|
||||
// write concept mutable down and clean it (dim0, dim1, shape(i), ...)
|
||||
#ifdef DO_NOT_DEFINE_ME
|
||||
// human version of the class, the preprocessor generalisation is next..
|
||||
template<typename ArrayType > class const_matrix_view_proxy<ArrayType,2> : TRIQS_MODEL_CONCEPT(ImmutableMatrix) {
|
||||
@ -47,9 +47,9 @@ namespace triqs { namespace arrays {
|
||||
typedef typename indexmap_type::domain_type domain_type;
|
||||
indexmap_type indexmap() const { return slicer_t::invoke(A->indexmap() , range() , range(),n, ellipsis()); }
|
||||
domain_type domain() const { return indexmap().domain();}
|
||||
size_t len(int i) const { return A->len(i);}
|
||||
size_t dim0() const { return A->len(0);}
|
||||
size_t dim1() const { return A->len(1);}
|
||||
size_t shape(int i) const { return A->shape(i);}
|
||||
size_t dim0() const { return A->shape(0);}
|
||||
size_t dim1() const { return A->shape(1);}
|
||||
typename ArrayType::storage_type const & storage() const { return A->storage();}
|
||||
TRIQS_DELETE_COMPOUND_OPERATORS(const_matrix_view_proxy);
|
||||
template< typename A0 , typename A1 , typename ... Args> value_type const & operator() ( A0 &&a0 , A1 &&a1 , Args && ... args) const
|
||||
@ -66,9 +66,9 @@ namespace triqs { namespace arrays {
|
||||
typedef typename indexmap_type::domain_type domain_type;
|
||||
indexmap_type indexmap() const { return slicer_t::invoke(A->indexmap() , range() , range(),n, ellipsis()); }
|
||||
domain_type domain() const { return indexmap().domain();}
|
||||
size_t len(int i) const { return A->len(i);}
|
||||
size_t dim0() const { return A->len(0);}
|
||||
size_t dim1() const { return A->len(1);}
|
||||
size_t shape(int i) const { return A->shape(i);}
|
||||
size_t dim0() const { return A->shape(0);}
|
||||
size_t dim1() const { return A->shape(1);}
|
||||
typename ArrayType::storage_type const & storage() const { return A->storage();}
|
||||
template<typename RHS> matrix_view_proxy & operator=(const RHS & X) {triqs_arrays_assign_delegation(*this,X); return *this; }
|
||||
TRIQS_DEFINE_COMPOUND_OPERATORS(matrix_view_proxy);
|
||||
@ -92,9 +92,9 @@ namespace triqs { namespace arrays {
|
||||
typedef typename indexmap_type::domain_type domain_type;\
|
||||
indexmap_type indexmap() const { return slicer_t::invoke(A->indexmap() BOOST_PP_ENUM_TRAILING(POS, TEXT, range()),n, ellipsis()); }\
|
||||
domain_type domain() const { return indexmap().domain();}\
|
||||
size_t len(int i) const { return A->len(i);}\
|
||||
size_t dim0() const { return A->len((POS+1)%3);}\
|
||||
size_t dim1() const { return A->len((POS+2)%3);}\
|
||||
size_t shape(int i) const { return A->shape(i);}\
|
||||
size_t dim0() const { return A->shape((POS+1)%3);}\
|
||||
size_t dim1() const { return A->shape((POS+2)%3);}\
|
||||
typename ArrayType::storage_type const & storage() const { return A->storage();}\
|
||||
value_type const * restrict data_start() const { return &storage()[indexmap().start_shift()];}\
|
||||
value_type * restrict data_start() { return &storage()[indexmap().start_shift()];}\
|
||||
@ -117,9 +117,9 @@ namespace triqs { namespace arrays {
|
||||
typedef typename indexmap_type::domain_type domain_type;\
|
||||
indexmap_type indexmap() const { return slicer_t::invoke(A->indexmap() BOOST_PP_ENUM_TRAILING(POS, TEXT, range()),n, ellipsis()); }\
|
||||
domain_type domain() const { return indexmap().domain();}\
|
||||
size_t len(int i) const { return A->len(i);}\
|
||||
size_t dim0() const { return A->len((POS+1)%3);}\
|
||||
size_t dim1() const { return A->len((POS+2)%3);}\
|
||||
size_t shape(int i) const { return A->shape(i);}\
|
||||
size_t dim0() const { return A->shape((POS+1)%3);}\
|
||||
size_t dim1() const { return A->shape((POS+2)%3);}\
|
||||
typename ArrayType::storage_type const & storage() const { return A->storage();}\
|
||||
value_type const * restrict data_start() const { return &storage()[indexmap().start_shift()];}\
|
||||
value_type * restrict data_start() { return &storage()[indexmap().start_shift()];}\
|
||||
|
@ -29,7 +29,7 @@ namespace triqs { namespace lattice_tools {
|
||||
//using triqs::arrays::blas::dot;
|
||||
const double almost_zero(1E-10);
|
||||
|
||||
bravais_lattice::bravais_lattice( units_type const & units__) : units_(3,3), dim_(units__.len(0)) {
|
||||
bravais_lattice::bravais_lattice( units_type const & units__) : units_(3,3), dim_(units__.shape(0)) {
|
||||
units_(range(0,dim_),range()) = units__();
|
||||
units_(range(dim_,3),range()) = 0;
|
||||
// First complete the basis. Add some tests for safety
|
||||
|
@ -31,8 +31,8 @@ using namespace std;
|
||||
|
||||
array_view <dcomplex,3> hopping_stack (tight_binding const & TB, array_view<double,2> const & k_stack) {
|
||||
auto TK = Fourier(TB);
|
||||
array<dcomplex,3> res(TB.n_bands(), TB.n_bands(), k_stack.len(1));
|
||||
for(size_t i = 0; i<k_stack.len(1); ++i) res(range(), range(), i) = TK(k_stack(range(),i));
|
||||
array<dcomplex,3> res(TB.n_bands(), TB.n_bands(), k_stack.shape(1));
|
||||
for(size_t i = 0; i<k_stack.shape(1); ++i) res(range(), range(), i) = TK(k_stack(range(),i));
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -131,14 +131,14 @@ using namespace std;
|
||||
|
||||
//const size_t ndim=TB.lattice().dim();
|
||||
//const size_t norb=TB.lattice().n_orbitals();
|
||||
int ntri = triangles.len(0)/3;
|
||||
int ntri = triangles.shape(0)/3;
|
||||
array<double,1> dos(neps);
|
||||
|
||||
// Check consistency
|
||||
const size_t ndim=TB.lattice().dim();
|
||||
//const size_t norb=TB.lattice().n_orbitals();
|
||||
if (ndim !=2) TRIQS_RUNTIME_ERROR<<"dos_patch : dimension 2 only !";
|
||||
if (triangles.len(1) != ndim) TRIQS_RUNTIME_ERROR<<"dos_patch : the second dimension of the 'triangle' array in not "<<ndim;
|
||||
if (triangles.shape(1) != ndim) TRIQS_RUNTIME_ERROR<<"dos_patch : the second dimension of the 'triangle' array in not "<<ndim;
|
||||
|
||||
// Every triangle has ndiv*ndiv k points
|
||||
size_t nk = ntri*ndiv*ndiv;
|
||||
|
@ -55,8 +55,8 @@ namespace triqs { namespace lattice_tools {
|
||||
std::vector<long> V(std::forward<VectorIntType>(v));
|
||||
if (v.size() != bl_.dim()) TRIQS_RUNTIME_ERROR<<"tight_binding : displacement of incorrect size : got "<< v.size() << "instead of "<< bl_.dim();
|
||||
matrix<dcomplex> M(std::forward<MatrixDComplexType>(m));
|
||||
if (M.len(0) != n_bands()) TRIQS_RUNTIME_ERROR<<"tight_binding : the first dim matrix is of size "<< M.len(0) <<" instead of "<< n_bands();
|
||||
if (M.len(1) != n_bands()) TRIQS_RUNTIME_ERROR<<"tight_binding : the first dim matrix is of size "<< M.len(1) <<" instead of "<< n_bands();
|
||||
if (M.shape(0) != n_bands()) TRIQS_RUNTIME_ERROR<<"tight_binding : the first dim matrix is of size "<< M.shape(0) <<" instead of "<< n_bands();
|
||||
if (M.shape(1) != n_bands()) TRIQS_RUNTIME_ERROR<<"tight_binding : the first dim matrix is of size "<< M.shape(1) <<" instead of "<< n_bands();
|
||||
displ_value_stack.push_back(std::make_pair(std::move(V), std::move(M)));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user