// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %rbx
subq $0xe8, %rsp
movsd %xmm0, 0x8(%rsp)
movq %rsi, %rbx
movq %rdi, %r14
callq 0x15274
movl %eax, %ebp
movq %rbx, %rdi
callq 0x15274
cmpl %eax, %ebp
jne 0xd31e
movq %r14, %rdi
callq 0x152d0
movl %eax, %ebp
movq %rbx, %rdi
callq 0x152d0
cmpl %eax, %ebp
jne 0xd31e
xorpd %xmm0, %xmm0
leaq 0xd0(%rsp), %rcx
movapd %xmm0, (%rcx)
movapd %xmm0, -0x10(%rcx)
movapd %xmm0, -0x20(%rcx)
movapd %xmm0, -0x30(%rcx)
andq $0x0, 0x10(%rcx)
leaq 0xb8(%rsp), %rdx
leaq 0xa0(%rsp), %rsi
movq %r14, %rdi
callq 0x15770
leaq 0x30(%rsp), %r15
xorpd %xmm0, %xmm0
movapd %xmm0, (%r15)
andq $0x0, 0x10(%r15)
movq %r14, %rdi
callq 0x15274
movl %eax, %ebp
movq %r14, %rdi
callq 0x152d0
leaq 0xa0(%rsp), %rdi
movq %r15, %rsi
movl %ebp, %edx
movl %eax, %ecx
callq 0x15eee
xorpd %xmm0, %xmm0
leaq 0x80(%rsp), %rcx
movapd %xmm0, (%rcx)
movapd %xmm0, -0x10(%rcx)
movapd %xmm0, -0x20(%rcx)
movapd %xmm0, -0x30(%rcx)
andq $0x0, 0x10(%rcx)
leaq 0x68(%rsp), %rdx
leaq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0x15770
leaq 0x10(%rsp), %r14
xorpd %xmm0, %xmm0
movapd %xmm0, (%r14)
andq $0x0, 0x10(%r14)
movq %rbx, %rdi
callq 0x15274
movl %eax, %ebp
movq %rbx, %rdi
callq 0x152d0
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
movl %ebp, %edx
movl %eax, %ecx
callq 0x15eee
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rax, %rcx
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rsi
subq %rdx, %rsi
cmpq %rsi, %rcx
movsd 0x8(%rsp), %xmm2
jne 0xd34e
sarq $0x3, %rcx
xorl %esi, %esi
movapd 0xf058(%rip), %xmm0     # 0x1c2f0
movl %esi, %esi
cmpq %rsi, %rcx
jbe 0xd2e5
movsd (%rax,%rsi,8), %xmm1
subsd (%rdx,%rsi,8), %xmm1
andpd %xmm0, %xmm1
incl %esi
ucomisd %xmm2, %xmm1
jbe 0xd298
pushq $0x10
popq %rdi
callq 0x20d0
movq %rax, %r14
leaq 0x103ec(%rip), %rsi     # 0x1d6b3
movq %rax, %rdi
callq 0x2080
movq 0x18d1a(%rip), %rsi     # 0x25ff0
movq 0x18ce3(%rip), %rdx     # 0x25fc0
movq %r14, %rdi
callq 0x2270
leaq 0x10(%rsp), %rdi
callq 0x1722c
leaq 0x50(%rsp), %rdi
callq 0x7dee
leaq 0x30(%rsp), %rdi
callq 0x1722c
leaq 0xa0(%rsp), %rdi
callq 0x7dee
addq $0xe8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x20d0
movq %rax, %r14
leaq 0xf5e9(%rip), %rsi      # 0x1c919
movq %rax, %rdi
callq 0x2080
movq 0x18cb1(%rip), %rsi     # 0x25ff0
movq 0x18c7a(%rip), %rdx     # 0x25fc0
movq %r14, %rdi
callq 0x2270
leaq 0xf5f1(%rip), %rdi      # 0x1c946
leaq 0xf613(%rip), %rsi      # 0x1c96f
leaq 0x102ba(%rip), %rcx     # 0x1d61d
pushq $0x5b
popq %rdx
callq 0x2100
jmp 0xd389
movq %rax, %rbx
jmp 0xd3a3
movq %rax, %rbx
jmp 0xd3ad
movq %rax, %rbx
jmp 0xd3b7
movq %rax, %rbx
movq %r14, %rdi
callq 0x2130
jmp 0xd3c4
movq %rax, %rbx
jmp 0xd399
movq %rax, %rbx
movq %r14, %rdi
callq 0x2130
leaq 0x10(%rsp), %rdi
callq 0x1722c
leaq 0x50(%rsp), %rdi
callq 0x7dee
leaq 0x30(%rsp), %rdi
callq 0x1722c
leaq 0xa0(%rsp), %rdi
callq 0x7dee
movq %rbx, %rdi
callq 0x2290