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
    Just keep in mind that if you are too concise you risk confusing your audience.2011-04-13
  • 0
    I'll explain what it means too.2011-04-13
  • 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
    That's not what I'm doing. It isn't a vector of ones. Only the kth element is one, so it would be something like [0, 0, 0, 0, 0, 1, 0, 0, 0], for example.2011-04-13
  • 0
    @mr banana : See edit. I believe $e_j$ is standard notation.2011-04-13
  • 0
    Not that I don't believe you, but could you tell me why is it e_j? I thought it would be something like 1_j. But thanks anyway.2011-04-13
  • 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 wiki 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