// File: yukimasano[P]cpp_matrix/Matrix.cpp
// Function: rand_basis_gs(Matrix&)
Matrix rand_basis_gs(Matrix& A){
  // using modified Gram-Schmidt
  assert(nrows(A)==ncols(A));
  int i = nrows(A);
  A = randm(A);
  Vector ve(i);
  for (int k=1;k<=i; k++){
    if (k==1){ve=A.get_col(k);}
    else{
      ve = A.get_col(k);
      // do the Gram-Schmidt
      for (int m=1; m<k;m++){
        ve = ve - (A.get_col(m)*A.get_col(k))* A.get_col(m);
      }
    }
    ve = ve/ve.norm();
    //A.set_col(k,ve);
    for (int j=1;j<=i; j++){
     A.set_val(j,k, ve(j));
    }
  }
return A;
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x38(%rsp)
movq %rdi, %rax
movq %rax, 0x40(%rsp)
movq %rdi, 0x130(%rsp)
movq %rsi, 0x128(%rsp)
movq 0x128(%rsp), %rdi
callq 0x3ac0
movl %eax, 0x48(%rsp)
movq 0x128(%rsp), %rdi
callq 0x3ad0
movl %eax, %ecx
movl 0x48(%rsp), %eax
cmpl %ecx, %eax
jne 0x525e
jmp 0x527d
leaq 0xa01d(%rip), %rdi      # 0xf282
leaq 0x9edd(%rip), %rsi      # 0xf149
movl $0x13c, %edx            # imm = 0x13C
leaq 0xa01d(%rip), %rcx      # 0xf295
callq 0x2090
movq 0x128(%rsp), %rdi
callq 0x3ac0
movl %eax, 0x124(%rsp)
movq 0x128(%rsp), %rsi
leaq 0x110(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x5140
movq 0x30(%rsp), %rsi
movq 0x128(%rsp), %rdi
callq 0x41e0
jmp 0x52bf
leaq 0x110(%rsp), %rdi
callq 0x3660
movl 0x124(%rsp), %esi
leaq 0xf0(%rsp), %rdi
callq 0xd040
movl $0x1, 0xec(%rsp)
movl 0xec(%rsp), %eax
cmpl 0x124(%rsp), %eax
jg 0x5717
cmpl $0x1, 0xec(%rsp)
jne 0x53b9
movq 0x128(%rsp), %rsi
movl 0xec(%rsp), %edx
leaq 0xd8(%rsp), %rdi
callq 0x3ae0
jmp 0x532b
leaq 0xf0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0xdc70
jmp 0x5342
leaq 0xd8(%rsp), %rdi
callq 0xd170
jmp 0x5611
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x3660
jmp 0x5752
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
jmp 0x5745
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0xd170
jmp 0x5745
movq 0x128(%rsp), %rsi
movl 0xec(%rsp), %edx
leaq 0xc8(%rsp), %rdi
callq 0x3ae0
jmp 0x53d7
leaq 0xf0(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0xdc70
jmp 0x53ee
leaq 0xc8(%rsp), %rdi
callq 0xd170
movl $0x1, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
cmpl 0xec(%rsp), %eax
jge 0x560f
movq 0x128(%rsp), %rsi
movl 0xc4(%rsp), %edx
leaq 0x88(%rsp), %rdi
callq 0x3ae0
jmp 0x5438
movq 0x128(%rsp), %rsi
movl 0xec(%rsp), %edx
leaq 0x78(%rsp), %rdi
callq 0x3ae0
jmp 0x5453
leaq 0x88(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0xd740
movsd %xmm0, 0x28(%rsp)
jmp 0x546d
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x98(%rsp)
movq 0x128(%rsp), %rsi
movl 0xc4(%rsp), %edx
leaq 0x68(%rsp), %rdi
callq 0x3ae0
jmp 0x5497
leaq 0xa0(%rsp), %rdi
leaq 0x98(%rsp), %rsi
leaq 0x68(%rsp), %rdx
callq 0xd910
jmp 0x54b3
leaq 0xb0(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
callq 0xd470
jmp 0x54d2
leaq 0xf0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0xdc70
jmp 0x54e9
leaq 0xb0(%rsp), %rdi
callq 0xd170
leaq 0xa0(%rsp), %rdi
callq 0xd170
leaq 0x68(%rsp), %rdi
callq 0xd170
leaq 0x78(%rsp), %rdi
callq 0xd170
leaq 0x88(%rsp), %rdi
callq 0xd170
movl 0xc4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc4(%rsp)
jmp 0x5406
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0xd170
jmp 0x5745
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
jmp 0x55fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
jmp 0x55f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
jmp 0x55e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
jmp 0x55dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0xd170
leaq 0xa0(%rsp), %rdi
callq 0xd170
leaq 0x68(%rsp), %rdi
callq 0xd170
leaq 0x78(%rsp), %rdi
callq 0xd170
leaq 0x88(%rsp), %rdi
callq 0xd170
jmp 0x5745
jmp 0x5611
leaq 0xf0(%rsp), %rdi
movl $0x2, %esi
callq 0xe320
movsd %xmm0, 0x20(%rsp)
jmp 0x562b
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0xd9c0
jmp 0x5650
leaq 0xf0(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0xdc70
jmp 0x5664
leaq 0x58(%rsp), %rdi
callq 0xd170
movl $0x1, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x124(%rsp), %eax
jg 0x56ff
movq 0x128(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0x4c(%rsp), %esi
movl %esi, 0x10(%rsp)
movl 0xec(%rsp), %eax
movl %eax, 0x14(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0xdee0
movq %rax, 0x18(%rsp)
jmp 0x56b7
movl 0x14(%rsp), %edx
movl 0x10(%rsp), %esi
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rax
movsd (%rax), %xmm0
callq 0x47c0
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x5676
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
leaq 0x58(%rsp), %rdi
callq 0xd170
jmp 0x5745
jmp 0x5701
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0x52eb
movq 0x38(%rsp), %rdi
movq 0x128(%rsp), %rsi
callq 0x5010
jmp 0x572b
leaq 0xf0(%rsp), %rdi
callq 0xd170
movq 0x40(%rsp), %rax
addq $0x138, %rsp            # imm = 0x138
retq
leaq 0xf0(%rsp), %rdi
callq 0xd170
movq 0x108(%rsp), %rdi
callq 0x21e0
nop