1
$\begingroup$

I'm doing a presentation and I have to include this in it:

for j in 1..j_max     b_offset = copy(b)     b_offset[j] = b_offset[j] + 1 

I can't do b_offset = b + 1, but I don't know how else to describe that just the jth index should increase by one.

  • 0
    Can you give a small example? Even though at this point you've accepted an answer, it is unclear what it is you want. The code you give doesn't seem to match the words '...just the $j$th index should increase by 1.". Why wouldn't you just say b[j] = b[j]+1, without all the looping?2011-04-13

1 Answers 1

1

Treating them as vectors, you could say

$\mathbf{b\_offset} = \mathbf{b} + \mathbf{e_j}$

where $\displaystyle \mathbf{e_j}$ is the unit vector with all zeroes except the $j^{th}$ co-ordinate.

  • 0
    @mr banana: I am not sure. Perhaps for Euclidean. See this: http://jeff560.tripod.com/matrices.html under section for Symbols for Vectors. The wi$k$i pages http://en.wikipedia.org/wiki/Euclidean_vector and http://en.wikipedia.org/wiki/Unit_vector seem to be using it too.2011-04-13