M = 3      
v = {{1, 1, 0}, {1, 0, 0}}
index = 
      Flatten[Table[{Permutations[v[[1]]][[i]], Permutations[
                v[[2]]][[j]]}, {i, M}, {j, M}], 1]

Permutations[{1, 1, 0}]
Permutations[{1, 1, 0}][[1]]
\(Table[{\(Permutations[{1, 1, 0}]\)[\([i]\)], 
        \(Permutations[{1, 0, 0}]\)[\([j]\)]}, {i, M}, {j, M}]\ 

    
\)index = 
      Flatten[Table[{Permutations[{1, 1, 0}][[i]], 
            Permutations[{1, 0, 0}][[j]]}, {i, M}, {j, M}], 1]

index[[1]] 
index[[1, 2]]
index[[1, 2, 1]]

plus[k_, sigma_][arg_] := 
      ReplacePart[arg, 1, {sigma, k}]
minus[k_, sigma_][arg_] := 
      ReplacePart[arg, 0, {sigma, k}]

minus[1, 1][v]
minus[1, 1][plus[1, 1][v]]

signn[1, 1][arg_] := 1
signn[k_, 1][arg_] := (-1)^
        Sum[arg[[1, i]], {i, 1, k - 1}]
signn[1, 2][arg_] :=   (-1)^
        Sum[arg[[1, i]], {i, 1, M}]
signn[k_, 2][
        arg_] := (-1)^(Sum[arg[[2, i]], {i, 1, k - 1}] + 
            Sum[arg[[1, i]], {i, 1, M}])

signn[
        3, 2][{{1, 0, 1}, {1, 1, 1}}]

c[k_, sigma_][0] := 0;
c[k_, sigma_][
        factor_. *s[arg_]] := 
      factor*(arg[[sigma, k]])*signn[k, sigma][arg]*
        s[minus[k, sigma][arg]]
cdg[k_, sigma_][0] := 0;
cdg[k_, sigma_][factor_. *s[arg_]] := 
          factor*(1 - arg[[sigma, k]])*signn[k, sigma][arg]*
            s[plus[k, sigma][arg]];
(* cdg1[k_, sigma_][0] := 0;
cdg1[k_, sigma_][factor_. *arg_] := 
            factor*(1 - arg[[sigma, k]])*signn[k, sigma][
                arg]*plus[k, sigma][arg] *)
c[M + 1, sigma_] := 
      c[1, sigma]
cdg[M + 1, sigma_] := cdg[1, sigma]

(* 
      at this point we have defined c and cdagger*) 
 cdg[M + 1, 1][s[v]] 
cdg[3, 2][2*s[v]] 
c[2, 1][s[v]] 
c[1, 1] [s[{{1, 1, 0}, {1, 0, 0}}]]  
cdg[3, 1] [  c[1, 1] [
        s[{{1, 1, 0}, {1, 0, 0}}]] ]

n[k_, sigma_][0] := 
      0
n[k_, sigma_][factor_. *s[arg_]] := 
      factor*arg[[sigma, k]]*s[arg]

n[1, 2][2*s[v]]
n[1, 2][s[{{0, 0, 0}, {1, 0, 0}}]]

(* The Hamiltonian *) 
H[vector_] := 
        Expand[            -t*
              Sum[cdg[k, sigma][ c[k + 1, sigma][
                      vector] ]  + cdg[k + 1, sigma][ c[k, sigma][
                      vector] ], 
                                       {k, M}, {sigma, 
                  2}] + 
                                       u*
              Sum[n[k, 1][n[k, 2][vector]], {k, 1, 
                  M}]];
H[s[index[[1]]]];

scalarp[a_, 0] := 0;
  
scalarp[a_, b_ + c_] := 
      scalarp[a, b] + scalarp[a, c]
scalarp[s[arg1_], factor_. *s[arg2_]] := 
      factor*If[arg1 == arg2, 1, 0]

MaxL = Length[index]
h1 = 
        Table[H[s[index[[j]] ]], {j, 
            MaxL}];
MatrixForm[h1]

h = (hlist = Table[H[s[index[ [j]] ]], {j, MaxL}]; 
          Table[scalarp[  s[ index[[i]] ], hlist[[j]] ],  {i, 
              MaxL}, {j, MaxL}]);
MatrixForm[h]

TeXForm[Eigenvalues[h]] >> hubbard.tex;

g[
        uu_] := Sort[
          Thread[ Eigensystem[ 
              N[ h /.  {t -> 1.0,  
                    u  ->  uu } ]]]] [[1, 2]]

gs[uu_]:=Sort[
        Thread[ Eigensystem[ 
            N[ h /.  {t -> 1.0,  
                  u  ->  uu } ]]]]

MatrixForm[gs[0]]
g[0]

Eigenvalues[h]

Thread[ f[{a1, a2}, {b1, b2}] ]  
(*  {vals, vecs} = Eigensystem[m]  *)

Sort[{4, 2, 3}]

f[x_] = t*x

ff = f[2]

N[ff  /. {t -> 2}]

?f