I want to make a matrix from 1D Arrays in Julia












0















I am new to Julia and need some help.
I have a list of 1D Arrays, I want to produce a matrix like this



   g = [ 2.0 -1.0  0.0  0.0; 
-1.0 2.0 -1.0 0.0;
0.0 -1.0 2.0 -1.0;
0.0 0.0 -1.0 3.0]


I am able to follow simple examples given on docs, but how do I achieve this using loops?



Cheers,
Ayush










share|improve this question


















  • 2





    Possible duplicate of How to convert Array{Array{Float64, 1}, 1} to Matrix in julia?

    – Colin T Bowers
    Nov 28 '18 at 5:58
















0















I am new to Julia and need some help.
I have a list of 1D Arrays, I want to produce a matrix like this



   g = [ 2.0 -1.0  0.0  0.0; 
-1.0 2.0 -1.0 0.0;
0.0 -1.0 2.0 -1.0;
0.0 0.0 -1.0 3.0]


I am able to follow simple examples given on docs, but how do I achieve this using loops?



Cheers,
Ayush










share|improve this question


















  • 2





    Possible duplicate of How to convert Array{Array{Float64, 1}, 1} to Matrix in julia?

    – Colin T Bowers
    Nov 28 '18 at 5:58














0












0








0








I am new to Julia and need some help.
I have a list of 1D Arrays, I want to produce a matrix like this



   g = [ 2.0 -1.0  0.0  0.0; 
-1.0 2.0 -1.0 0.0;
0.0 -1.0 2.0 -1.0;
0.0 0.0 -1.0 3.0]


I am able to follow simple examples given on docs, but how do I achieve this using loops?



Cheers,
Ayush










share|improve this question














I am new to Julia and need some help.
I have a list of 1D Arrays, I want to produce a matrix like this



   g = [ 2.0 -1.0  0.0  0.0; 
-1.0 2.0 -1.0 0.0;
0.0 -1.0 2.0 -1.0;
0.0 0.0 -1.0 3.0]


I am able to follow simple examples given on docs, but how do I achieve this using loops?



Cheers,
Ayush







julia






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 28 '18 at 5:18









Ayush PatnaikAyush Patnaik

1




1








  • 2





    Possible duplicate of How to convert Array{Array{Float64, 1}, 1} to Matrix in julia?

    – Colin T Bowers
    Nov 28 '18 at 5:58














  • 2





    Possible duplicate of How to convert Array{Array{Float64, 1}, 1} to Matrix in julia?

    – Colin T Bowers
    Nov 28 '18 at 5:58








2




2





Possible duplicate of How to convert Array{Array{Float64, 1}, 1} to Matrix in julia?

– Colin T Bowers
Nov 28 '18 at 5:58





Possible duplicate of How to convert Array{Array{Float64, 1}, 1} to Matrix in julia?

– Colin T Bowers
Nov 28 '18 at 5:58












1 Answer
1






active

oldest

votes


















1














with loops you can create a matrix and then fill it.



with loops



horizontally:



julia> arr = [[2.0,-1.0,0.0,0.0],[-1.0,2.0,-1.0,0.0],[0.0,-1.0,2.0,-1.0],[0.0,0.0,-1.0,3.0],[1.,1.,1.,1.]]
5-element Array{Array{Float64,1},1}:
[2.0, -1.0, 0.0, 0.0]
[-1.0, 2.0, -1.0, 0.0]
[0.0, -1.0, 2.0, -1.0]
[0.0, 0.0, -1.0, 3.0]
[1.0, 1.0, 1.0, 1.0]

julia> function make_matrix(input::Vector{<:Vector})
element_type = eltype(eltype(input))
if (length(input) == 0)
return Array{element_type,2}(undef,0,0)
end

height,width = length(input[1]), length(input)

for col in input
(height == length(col)) ? nothing : throw("inconsistent array size")
end

output = Array{element_type}(undef,height,width)

for i in 1:width
output[:,i] = input[i]
end

return output
end
make_matrix (generic function with 1 method)

julia> make_matrix(arr)
4×5 Array{Float64,2}:
2.0 -1.0 0.0 0.0 1.0
-1.0 2.0 -1.0 0.0 1.0
0.0 -1.0 2.0 -1.0 1.0
0.0 0.0 -1.0 3.0 1.0


vertically:



julia> function vmake_matrix(input::Vector{<:Vector})
element_type = eltype(eltype(input))
if (length(input) == 0)
return Array{element_type,2}(undef,0,0)
end

height,width = length(input),length(input[1])

for col in input
(width == length(col)) ? nothing : throw("inconsistent array size")
end

output = Array{element_type}(undef,height,width)

for i in 1:height
output[i,:] = input[i]
end

return output
end
vmake_matrix (generic function with 1 method)

julia> vmake_matrix(arr)
5×4 Array{Float64,2}:
2.0 -1.0 0.0 0.0
-1.0 2.0 -1.0 0.0
0.0 -1.0 2.0 -1.0
0.0 0.0 -1.0 3.0
1.0 1.0 1.0 1.0


without loops



without loops you can use vcat or hcat depending on the direction you want to concatenate the arrays in.



julia> H_arr = [ [ 2.0 -1.0  0.0  0.0],[-1.0  2.0 -1.0  0.0],[0.0 -1.0  2.0 -1.0],[0.0  0.0 -1.0  3.0] ]
4-element Array{Array{Float64,2},1}:
[2.0 -1.0 0.0 0.0]
[-1.0 2.0 -1.0 0.0]
[0.0 -1.0 2.0 -1.0]
[0.0 0.0 -1.0 3.0]

julia> vcat(H_arr...)
4×4 Array{Float64,2}:
2.0 -1.0 0.0 0.0
-1.0 2.0 -1.0 0.0
0.0 -1.0 2.0 -1.0
0.0 0.0 -1.0 3.0

julia> V_arr = [[2.0,-1.0,0.0,0.0],[-1.0,2.0,-1.0,0.0],[0.0,-1.0,2.0,-1.0],[0.0,0.0,-1.0,3.0]]
4-element Array{Array{Float64,1},1}:
[2.0, -1.0, 0.0, 0.0]
[-1.0, 2.0, -1.0, 0.0]
[0.0, -1.0, 2.0, -1.0]
[0.0, 0.0, -1.0, 3.0]

julia> hcat(V_arr...)
4×4 Array{Float64,2}:
2.0 -1.0 0.0 0.0
-1.0 2.0 -1.0 0.0
0.0 -1.0 2.0 -1.0
0.0 0.0 -1.0 3.0





share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53512614%2fi-want-to-make-a-matrix-from-1d-arrays-in-julia%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    with loops you can create a matrix and then fill it.



    with loops



    horizontally:



    julia> arr = [[2.0,-1.0,0.0,0.0],[-1.0,2.0,-1.0,0.0],[0.0,-1.0,2.0,-1.0],[0.0,0.0,-1.0,3.0],[1.,1.,1.,1.]]
    5-element Array{Array{Float64,1},1}:
    [2.0, -1.0, 0.0, 0.0]
    [-1.0, 2.0, -1.0, 0.0]
    [0.0, -1.0, 2.0, -1.0]
    [0.0, 0.0, -1.0, 3.0]
    [1.0, 1.0, 1.0, 1.0]

    julia> function make_matrix(input::Vector{<:Vector})
    element_type = eltype(eltype(input))
    if (length(input) == 0)
    return Array{element_type,2}(undef,0,0)
    end

    height,width = length(input[1]), length(input)

    for col in input
    (height == length(col)) ? nothing : throw("inconsistent array size")
    end

    output = Array{element_type}(undef,height,width)

    for i in 1:width
    output[:,i] = input[i]
    end

    return output
    end
    make_matrix (generic function with 1 method)

    julia> make_matrix(arr)
    4×5 Array{Float64,2}:
    2.0 -1.0 0.0 0.0 1.0
    -1.0 2.0 -1.0 0.0 1.0
    0.0 -1.0 2.0 -1.0 1.0
    0.0 0.0 -1.0 3.0 1.0


    vertically:



    julia> function vmake_matrix(input::Vector{<:Vector})
    element_type = eltype(eltype(input))
    if (length(input) == 0)
    return Array{element_type,2}(undef,0,0)
    end

    height,width = length(input),length(input[1])

    for col in input
    (width == length(col)) ? nothing : throw("inconsistent array size")
    end

    output = Array{element_type}(undef,height,width)

    for i in 1:height
    output[i,:] = input[i]
    end

    return output
    end
    vmake_matrix (generic function with 1 method)

    julia> vmake_matrix(arr)
    5×4 Array{Float64,2}:
    2.0 -1.0 0.0 0.0
    -1.0 2.0 -1.0 0.0
    0.0 -1.0 2.0 -1.0
    0.0 0.0 -1.0 3.0
    1.0 1.0 1.0 1.0


    without loops



    without loops you can use vcat or hcat depending on the direction you want to concatenate the arrays in.



    julia> H_arr = [ [ 2.0 -1.0  0.0  0.0],[-1.0  2.0 -1.0  0.0],[0.0 -1.0  2.0 -1.0],[0.0  0.0 -1.0  3.0] ]
    4-element Array{Array{Float64,2},1}:
    [2.0 -1.0 0.0 0.0]
    [-1.0 2.0 -1.0 0.0]
    [0.0 -1.0 2.0 -1.0]
    [0.0 0.0 -1.0 3.0]

    julia> vcat(H_arr...)
    4×4 Array{Float64,2}:
    2.0 -1.0 0.0 0.0
    -1.0 2.0 -1.0 0.0
    0.0 -1.0 2.0 -1.0
    0.0 0.0 -1.0 3.0

    julia> V_arr = [[2.0,-1.0,0.0,0.0],[-1.0,2.0,-1.0,0.0],[0.0,-1.0,2.0,-1.0],[0.0,0.0,-1.0,3.0]]
    4-element Array{Array{Float64,1},1}:
    [2.0, -1.0, 0.0, 0.0]
    [-1.0, 2.0, -1.0, 0.0]
    [0.0, -1.0, 2.0, -1.0]
    [0.0, 0.0, -1.0, 3.0]

    julia> hcat(V_arr...)
    4×4 Array{Float64,2}:
    2.0 -1.0 0.0 0.0
    -1.0 2.0 -1.0 0.0
    0.0 -1.0 2.0 -1.0
    0.0 0.0 -1.0 3.0





    share|improve this answer






























      1














      with loops you can create a matrix and then fill it.



      with loops



      horizontally:



      julia> arr = [[2.0,-1.0,0.0,0.0],[-1.0,2.0,-1.0,0.0],[0.0,-1.0,2.0,-1.0],[0.0,0.0,-1.0,3.0],[1.,1.,1.,1.]]
      5-element Array{Array{Float64,1},1}:
      [2.0, -1.0, 0.0, 0.0]
      [-1.0, 2.0, -1.0, 0.0]
      [0.0, -1.0, 2.0, -1.0]
      [0.0, 0.0, -1.0, 3.0]
      [1.0, 1.0, 1.0, 1.0]

      julia> function make_matrix(input::Vector{<:Vector})
      element_type = eltype(eltype(input))
      if (length(input) == 0)
      return Array{element_type,2}(undef,0,0)
      end

      height,width = length(input[1]), length(input)

      for col in input
      (height == length(col)) ? nothing : throw("inconsistent array size")
      end

      output = Array{element_type}(undef,height,width)

      for i in 1:width
      output[:,i] = input[i]
      end

      return output
      end
      make_matrix (generic function with 1 method)

      julia> make_matrix(arr)
      4×5 Array{Float64,2}:
      2.0 -1.0 0.0 0.0 1.0
      -1.0 2.0 -1.0 0.0 1.0
      0.0 -1.0 2.0 -1.0 1.0
      0.0 0.0 -1.0 3.0 1.0


      vertically:



      julia> function vmake_matrix(input::Vector{<:Vector})
      element_type = eltype(eltype(input))
      if (length(input) == 0)
      return Array{element_type,2}(undef,0,0)
      end

      height,width = length(input),length(input[1])

      for col in input
      (width == length(col)) ? nothing : throw("inconsistent array size")
      end

      output = Array{element_type}(undef,height,width)

      for i in 1:height
      output[i,:] = input[i]
      end

      return output
      end
      vmake_matrix (generic function with 1 method)

      julia> vmake_matrix(arr)
      5×4 Array{Float64,2}:
      2.0 -1.0 0.0 0.0
      -1.0 2.0 -1.0 0.0
      0.0 -1.0 2.0 -1.0
      0.0 0.0 -1.0 3.0
      1.0 1.0 1.0 1.0


      without loops



      without loops you can use vcat or hcat depending on the direction you want to concatenate the arrays in.



      julia> H_arr = [ [ 2.0 -1.0  0.0  0.0],[-1.0  2.0 -1.0  0.0],[0.0 -1.0  2.0 -1.0],[0.0  0.0 -1.0  3.0] ]
      4-element Array{Array{Float64,2},1}:
      [2.0 -1.0 0.0 0.0]
      [-1.0 2.0 -1.0 0.0]
      [0.0 -1.0 2.0 -1.0]
      [0.0 0.0 -1.0 3.0]

      julia> vcat(H_arr...)
      4×4 Array{Float64,2}:
      2.0 -1.0 0.0 0.0
      -1.0 2.0 -1.0 0.0
      0.0 -1.0 2.0 -1.0
      0.0 0.0 -1.0 3.0

      julia> V_arr = [[2.0,-1.0,0.0,0.0],[-1.0,2.0,-1.0,0.0],[0.0,-1.0,2.0,-1.0],[0.0,0.0,-1.0,3.0]]
      4-element Array{Array{Float64,1},1}:
      [2.0, -1.0, 0.0, 0.0]
      [-1.0, 2.0, -1.0, 0.0]
      [0.0, -1.0, 2.0, -1.0]
      [0.0, 0.0, -1.0, 3.0]

      julia> hcat(V_arr...)
      4×4 Array{Float64,2}:
      2.0 -1.0 0.0 0.0
      -1.0 2.0 -1.0 0.0
      0.0 -1.0 2.0 -1.0
      0.0 0.0 -1.0 3.0





      share|improve this answer




























        1












        1








        1







        with loops you can create a matrix and then fill it.



        with loops



        horizontally:



        julia> arr = [[2.0,-1.0,0.0,0.0],[-1.0,2.0,-1.0,0.0],[0.0,-1.0,2.0,-1.0],[0.0,0.0,-1.0,3.0],[1.,1.,1.,1.]]
        5-element Array{Array{Float64,1},1}:
        [2.0, -1.0, 0.0, 0.0]
        [-1.0, 2.0, -1.0, 0.0]
        [0.0, -1.0, 2.0, -1.0]
        [0.0, 0.0, -1.0, 3.0]
        [1.0, 1.0, 1.0, 1.0]

        julia> function make_matrix(input::Vector{<:Vector})
        element_type = eltype(eltype(input))
        if (length(input) == 0)
        return Array{element_type,2}(undef,0,0)
        end

        height,width = length(input[1]), length(input)

        for col in input
        (height == length(col)) ? nothing : throw("inconsistent array size")
        end

        output = Array{element_type}(undef,height,width)

        for i in 1:width
        output[:,i] = input[i]
        end

        return output
        end
        make_matrix (generic function with 1 method)

        julia> make_matrix(arr)
        4×5 Array{Float64,2}:
        2.0 -1.0 0.0 0.0 1.0
        -1.0 2.0 -1.0 0.0 1.0
        0.0 -1.0 2.0 -1.0 1.0
        0.0 0.0 -1.0 3.0 1.0


        vertically:



        julia> function vmake_matrix(input::Vector{<:Vector})
        element_type = eltype(eltype(input))
        if (length(input) == 0)
        return Array{element_type,2}(undef,0,0)
        end

        height,width = length(input),length(input[1])

        for col in input
        (width == length(col)) ? nothing : throw("inconsistent array size")
        end

        output = Array{element_type}(undef,height,width)

        for i in 1:height
        output[i,:] = input[i]
        end

        return output
        end
        vmake_matrix (generic function with 1 method)

        julia> vmake_matrix(arr)
        5×4 Array{Float64,2}:
        2.0 -1.0 0.0 0.0
        -1.0 2.0 -1.0 0.0
        0.0 -1.0 2.0 -1.0
        0.0 0.0 -1.0 3.0
        1.0 1.0 1.0 1.0


        without loops



        without loops you can use vcat or hcat depending on the direction you want to concatenate the arrays in.



        julia> H_arr = [ [ 2.0 -1.0  0.0  0.0],[-1.0  2.0 -1.0  0.0],[0.0 -1.0  2.0 -1.0],[0.0  0.0 -1.0  3.0] ]
        4-element Array{Array{Float64,2},1}:
        [2.0 -1.0 0.0 0.0]
        [-1.0 2.0 -1.0 0.0]
        [0.0 -1.0 2.0 -1.0]
        [0.0 0.0 -1.0 3.0]

        julia> vcat(H_arr...)
        4×4 Array{Float64,2}:
        2.0 -1.0 0.0 0.0
        -1.0 2.0 -1.0 0.0
        0.0 -1.0 2.0 -1.0
        0.0 0.0 -1.0 3.0

        julia> V_arr = [[2.0,-1.0,0.0,0.0],[-1.0,2.0,-1.0,0.0],[0.0,-1.0,2.0,-1.0],[0.0,0.0,-1.0,3.0]]
        4-element Array{Array{Float64,1},1}:
        [2.0, -1.0, 0.0, 0.0]
        [-1.0, 2.0, -1.0, 0.0]
        [0.0, -1.0, 2.0, -1.0]
        [0.0, 0.0, -1.0, 3.0]

        julia> hcat(V_arr...)
        4×4 Array{Float64,2}:
        2.0 -1.0 0.0 0.0
        -1.0 2.0 -1.0 0.0
        0.0 -1.0 2.0 -1.0
        0.0 0.0 -1.0 3.0





        share|improve this answer















        with loops you can create a matrix and then fill it.



        with loops



        horizontally:



        julia> arr = [[2.0,-1.0,0.0,0.0],[-1.0,2.0,-1.0,0.0],[0.0,-1.0,2.0,-1.0],[0.0,0.0,-1.0,3.0],[1.,1.,1.,1.]]
        5-element Array{Array{Float64,1},1}:
        [2.0, -1.0, 0.0, 0.0]
        [-1.0, 2.0, -1.0, 0.0]
        [0.0, -1.0, 2.0, -1.0]
        [0.0, 0.0, -1.0, 3.0]
        [1.0, 1.0, 1.0, 1.0]

        julia> function make_matrix(input::Vector{<:Vector})
        element_type = eltype(eltype(input))
        if (length(input) == 0)
        return Array{element_type,2}(undef,0,0)
        end

        height,width = length(input[1]), length(input)

        for col in input
        (height == length(col)) ? nothing : throw("inconsistent array size")
        end

        output = Array{element_type}(undef,height,width)

        for i in 1:width
        output[:,i] = input[i]
        end

        return output
        end
        make_matrix (generic function with 1 method)

        julia> make_matrix(arr)
        4×5 Array{Float64,2}:
        2.0 -1.0 0.0 0.0 1.0
        -1.0 2.0 -1.0 0.0 1.0
        0.0 -1.0 2.0 -1.0 1.0
        0.0 0.0 -1.0 3.0 1.0


        vertically:



        julia> function vmake_matrix(input::Vector{<:Vector})
        element_type = eltype(eltype(input))
        if (length(input) == 0)
        return Array{element_type,2}(undef,0,0)
        end

        height,width = length(input),length(input[1])

        for col in input
        (width == length(col)) ? nothing : throw("inconsistent array size")
        end

        output = Array{element_type}(undef,height,width)

        for i in 1:height
        output[i,:] = input[i]
        end

        return output
        end
        vmake_matrix (generic function with 1 method)

        julia> vmake_matrix(arr)
        5×4 Array{Float64,2}:
        2.0 -1.0 0.0 0.0
        -1.0 2.0 -1.0 0.0
        0.0 -1.0 2.0 -1.0
        0.0 0.0 -1.0 3.0
        1.0 1.0 1.0 1.0


        without loops



        without loops you can use vcat or hcat depending on the direction you want to concatenate the arrays in.



        julia> H_arr = [ [ 2.0 -1.0  0.0  0.0],[-1.0  2.0 -1.0  0.0],[0.0 -1.0  2.0 -1.0],[0.0  0.0 -1.0  3.0] ]
        4-element Array{Array{Float64,2},1}:
        [2.0 -1.0 0.0 0.0]
        [-1.0 2.0 -1.0 0.0]
        [0.0 -1.0 2.0 -1.0]
        [0.0 0.0 -1.0 3.0]

        julia> vcat(H_arr...)
        4×4 Array{Float64,2}:
        2.0 -1.0 0.0 0.0
        -1.0 2.0 -1.0 0.0
        0.0 -1.0 2.0 -1.0
        0.0 0.0 -1.0 3.0

        julia> V_arr = [[2.0,-1.0,0.0,0.0],[-1.0,2.0,-1.0,0.0],[0.0,-1.0,2.0,-1.0],[0.0,0.0,-1.0,3.0]]
        4-element Array{Array{Float64,1},1}:
        [2.0, -1.0, 0.0, 0.0]
        [-1.0, 2.0, -1.0, 0.0]
        [0.0, -1.0, 2.0, -1.0]
        [0.0, 0.0, -1.0, 3.0]

        julia> hcat(V_arr...)
        4×4 Array{Float64,2}:
        2.0 -1.0 0.0 0.0
        -1.0 2.0 -1.0 0.0
        0.0 -1.0 2.0 -1.0
        0.0 0.0 -1.0 3.0






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 28 '18 at 17:26

























        answered Nov 28 '18 at 16:54









        WarrenWarren

        1486




        1486
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53512614%2fi-want-to-make-a-matrix-from-1d-arrays-in-julia%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks