You can use Householder matrices to do this. See for
example http://en.wikipedia.org/wiki/Householder_reflection
and http://en.wikipedia.org/wiki/QR_decomposition
One can find a Householder matrix Q so that Q*u = e_1
(where e_k is the vector that's all 0s apart from a 1 in the k-th place)
Then if f_k = Q*e_k, the f_k form an orthogonal basis and f_1 = u.
(Since Q*Q = I, and Q is orthogonal.)
All this talk of matrices might make it seem that the routine
would be expensive, but this is not so. For example this C function,
given a vector of length 1 returns an array with the required basis
in column order, ie the j'th component of the i'th vector is held in b[j+dim*i]
double* make_basis( int dim, const double* v)
{
double* B = calloc( dim*dim, sizeof * B);
double* h = calloc( dim, sizeof *h);
double f, s, d;
int i, j;
/* compute Householder vector and factor */
memcpy( h, v, dim*sizeof *h);
s = ( v[0] > 0.0) ? 1.0 : -1.0;
h[0] += s;
f = s/(s+v[0]);
/* compute basis */
memcpy( B, v, dim * sizeof *v); /* first one is v */
/* others by applying Householder matrix */
for( i=1; i<dim; ++i)
{ d = f*h[i];
for( j=0; j<dim; ++j)
{ B[dim*i+j] = (i==j) - d*h[j];
}
}
free( h);
return B;
}