// File: toxaart[P]hierarchical_block_sparse_lib/test_source/./test_utils.h
// Function: void verify_that_matrices_are_almost_equal<hbsm::HierarchicalBlockSparseMatrix<double>>(hbsm::HierarchicalBlockSparseMatrix<double> const&, hbsm::HierarchicalBlockSparseMatrix<double> const&, double)
void verify_that_matrices_are_almost_equal(const MatrixType & A,
					   const MatrixType & B,
					   double tolerance) {
  if(A.get_n_rows() != B.get_n_rows() || A.get_n_cols() != B.get_n_cols())
    throw std::runtime_error("Error: matrices do not have same dimensions.");
  SparseMatrix spA;
  A.get_all_values(spA.rows, spA.cols, spA.values);
  std::vector<double> fullMatrixA;
  spA.to_full(fullMatrixA, A.get_n_rows(), A.get_n_cols());
  SparseMatrix spB;
  B.get_all_values(spB.rows, spB.cols, spB.values);
  std::vector<double> fullMatrixB;
  spB.to_full(fullMatrixB, B.get_n_rows(), B.get_n_cols());

  assert( fullMatrixA.size() == fullMatrixB.size() );
  for(unsigned int ind=0; ind<fullMatrixA.size(); ind++) {
    if (verbose)
      std::cout << std::setw(5) << ind << "  " 
		<< std::setw(14) << fullMatrixA[ind] << "  " 
		<< std::setw(14) << fullMatrixB[ind] 
		<< std::endl;
    if(std::fabs(fullMatrixA[ind] - fullMatrixB[ind]) > tolerance)
      throw std::runtime_error("Error: matrices not almost equal.");
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x24470
movl %eax, -0xf0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x24470
movl %eax, %ecx
movl -0xf0(%rbp), %eax
cmpl %ecx, %eax
jne 0x13850
movq -0x8(%rbp), %rdi
callq 0x24540
movl %eax, -0xf4(%rbp)
movq -0x10(%rbp), %rdi
callq 0x24540
movl %eax, %ecx
movl -0xf4(%rbp), %eax
cmpl %ecx, %eax
je 0x138ac
movl $0x10, %edi
callq 0x20d0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x100(%rbp)
leaq 0x2307b(%rip), %rsi     # 0x368e9
callq 0x20a0
jmp 0x13875
movq -0x100(%rbp), %rdi
movq 0x2d76d(%rip), %rsi     # 0x40ff0
movq 0x2d736(%rip), %rdx     # 0x40fc0
callq 0x2320
movq -0x100(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x2150
jmp 0x13b88
leaq -0x70(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x8750
movq -0x108(%rbp), %rsi
movq -0x8(%rbp), %rdi
leaq -0x58(%rbp), %rdx
leaq -0x40(%rbp), %rcx
callq 0x257e0
jmp 0x138d6
leaq -0x88(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x10e80
movq -0x8(%rbp), %rdi
callq 0x24470
movl %eax, -0x10c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x24540
movq -0x118(%rbp), %rsi
movl -0x10c(%rbp), %edx
movl %eax, %ecx
leaq -0x70(%rbp), %rdi
callq 0x262a0
jmp 0x1391b
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x8750
movq -0x120(%rbp), %rsi
movq -0x10(%rbp), %rdi
leaq -0xb8(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
callq 0x257e0
jmp 0x1394e
leaq -0xe8(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x10e80
movq -0x10(%rbp), %rdi
callq 0x24470
movl %eax, -0x124(%rbp)
movq -0x10(%rbp), %rdi
callq 0x24540
movq -0x130(%rbp), %rsi
movl -0x124(%rbp), %edx
movl %eax, %ecx
leaq -0xd0(%rbp), %rdi
callq 0x262a0
jmp 0x13996
leaq -0x88(%rbp), %rdi
callq 0x22b40
movq %rax, -0x138(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x22b40
movq %rax, %rcx
movq -0x138(%rbp), %rax
cmpq %rcx, %rax
jne 0x139c6
jmp 0x13a29
leaq 0x22f49(%rip), %rdi     # 0x36916
leaq 0x22f6b(%rip), %rsi     # 0x3693f
movl $0x5b, %edx
leaq 0x23c0d(%rip), %rcx     # 0x375ed
callq 0x2120
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x13b7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x13b73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x13b67
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x13b5b
movl $0x0, -0xec(%rbp)
movl -0xec(%rbp), %eax
movq %rax, -0x140(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x22b40
movq %rax, %rcx
movq -0x140(%rbp), %rax
cmpq %rcx, %rax
jae 0x13b25
movl -0xec(%rbp), %eax
movl %eax, %esi
leaq -0x88(%rbp), %rdi
callq 0x22b60
movsd (%rax), %xmm0
movsd %xmm0, -0x148(%rbp)
movl -0xec(%rbp), %eax
movl %eax, %esi
leaq -0xe8(%rbp), %rdi
callq 0x22b60
movsd -0x148(%rbp), %xmm0
subsd (%rax), %xmm0
movaps 0x2282a(%rip), %xmm1    # 0x362d0
pand %xmm1, %xmm0
ucomisd -0x18(%rbp), %xmm0
jbe 0x13b0f
movl $0x10, %edi
callq 0x20d0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x150(%rbp)
leaq 0x23bb4(%rip), %rsi     # 0x37683
callq 0x20a0
jmp 0x13ad6
movq -0x150(%rbp), %rdi
movq 0x2d50c(%rip), %rsi     # 0x40ff0
movq 0x2d4d5(%rip), %rdx     # 0x40fc0
callq 0x2320
jmp 0x13b91
movq -0x150(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x2150
jmp 0x13b5b
jmp 0x13b11
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
jmp 0x13a33
leaq -0xe8(%rbp), %rdi
callq 0x112e0
leaq -0xd0(%rbp), %rdi
callq 0x87d0
leaq -0x88(%rbp), %rdi
callq 0x112e0
leaq -0x70(%rbp), %rdi
callq 0x87d0
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
leaq -0xe8(%rbp), %rdi
callq 0x112e0
leaq -0xd0(%rbp), %rdi
callq 0x87d0
leaq -0x88(%rbp), %rdi
callq 0x112e0
leaq -0x70(%rbp), %rdi
callq 0x87d0
movq -0x20(%rbp), %rdi
callq 0x2340
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)