Skip to content

Commit b8dafe5

Browse files
authored
Merge pull request #309 from gridap/add_setindex_to_reindexed_array
Added setindex! method for Reindexed.
2 parents a8aa850 + 46948ae commit b8dafe5

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

NEWS.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- New `CDLagrangianRefFE` struct, that provides a Lagrangian reference FE with different conformity per direction. Since PR [#299](https://github.com/gridap/Gridap.jl/pull/299).
1616
- New `FESpace` method that takes a model and a `RefFE`. Since PR [#299](https://github.com/gridap/Gridap.jl/pull/299).
1717
- Possibility to have 0 order in `DISC` directions of a `CDLagrangianRefFE`. Since PR [#308](https://github.com/gridap/Gridap.jl/pull/308).
18+
- Added setindex! method for Reindexed. Since PR [#309](https://github.com/gridap/Gridap.jl/pull/309).
1819

1920
### Changed
2021

src/Arrays/Reindex.jl

+7
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ end
4343
a.i_to_v[i]
4444
end
4545

46+
@propagate_inbounds function Base.setindex!(a::Reindexed,v,j::Integer)
47+
i = a.j_to_i[j]
48+
a.i_to_v[i]=v
49+
end
50+
51+
52+
4653
function testitem(a::Reindexed)
4754
if length(a.j_to_i) == 0
4855
testitem(a.i_to_v)

test/ArraysTests/ReindexTests.jl

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ using FillArrays
55
using Gridap.Arrays
66
using Gridap.Arrays: AppliedArray
77

8+
a = [1,2,3]
9+
b = reindex(a,[3,2,1])
10+
for i=1:3
11+
b[i]=i
12+
end
13+
@test b == [1,2,3]
14+
@test a == [3,2,1]
15+
816
a = [[1,2,4,5],[2,4,6,7],[4,3,5,1],[2,3]]
917
b = [3,1,2]
1018

0 commit comments

Comments
 (0)