// File: /workspace/github_cpp_makefile_star2_O2/toxaart[P]hierarchical_block_sparse_lib/source/HierarchicalBlockSparseMatrix.h
// Function: hbsm::HierarchicalBlockSparseMatrix<double>::add_scaled_identity(hbsm::HierarchicalBlockSparseMatrix<double> const&, double)
void HierarchicalBlockSparseMatrix<Treal>::add_scaled_identity(const HierarchicalBlockSparseMatrix<Treal> & other, Treal alpha) {

			if(other.empty()){
				throw std::runtime_error("Error in HierarchicalBlockSparseMatrix::add_scaled_identity(): empty matrix as input!");
			}

			if(other.nRows != other.nCols)
				throw std::runtime_error("Error in HierarchicalBlockSparseMatrix::add_scaled_identity(): non-square matrix as input!");

			this->clear();

			this->set_params(other.get_params());

			this->resize(other.nRows_orig,other.nCols_orig);

			if(other.lowest_level()){
				memcpy(&submatrix[0], &(other.submatrix[0]), sizeof(Treal) * other.submatrix.size());
				for(int i = 0; i < nRows; ++i){
					submatrix[i*nRows + i] += alpha;
				}

				return;
			}

			//non-leaf case
			if(other.children[1] != NULL){
				children[1] = std::make_shared<HierarchicalBlockSparseMatrix<Treal> >();
				children[1]->parent = this;
				children[1]->copy(*(other.children[1]));
			}

			if(other.children[2] != NULL){
				children[2] = std::make_shared<HierarchicalBlockSparseMatrix<Treal> >();
				children[2]->parent = this;
				children[2]->copy(*(other.children[2]));
			}


			if(other.children[0] != NULL){

				if(children[0] != NULL) throw std::runtime_error("Error in HierarchicalBlockSparseMatrix::add_scaled_identity(): non-null child0 occured");
				children[0] = std::make_shared<HierarchicalBlockSparseMatrix<Treal> >();
				children[0]->parent = this;
				children[0]->add_scaled_identity(*other.children[0],alpha);

			}
			else{

				if(children[0] != NULL) throw std::runtime_error("Error in HierarchicalBlockSparseMatrix::add_scaled_identity(): non-null child0 occured");

				children[0] = std::make_shared<HierarchicalBlockSparseMatrix<Treal> >();
				children[0]->parent = this;
				children[0]->set_params(get_params());
				children[0]->resize(nRows/2, nCols/2);

				std::vector<int> rows, cols;
				std::vector<Treal> vals;

				rows.resize(nRows/2);
				cols.resize(nRows/2);
				vals.resize(nRows/2);

				for(int i = 0; i < nRows/2; ++i){
					rows[i] = i;
					cols[i] = i;
					vals[i] = alpha;
				}

				children[0]->assign_from_vectors(rows, cols, vals);
			}


			if(other.children[3] != NULL){

				if(children[3] != NULL) throw std::runtime_error("Error in HierarchicalBlockSparseMatrix::add_scaled_identity(): non-null child3 occured");

				children[3] = std::make_shared<HierarchicalBlockSparseMatrix<Treal> >();

				children[3]->parent = this;

				children[3]->add_scaled_identity(*other.children[3],alpha);

			}
			else{

				if(children[3] != NULL) throw std::runtime_error("Error in HierarchicalBlockSparseMatrix::add_scaled_identity(): non-null child3 occured");

				children[3] = std::make_shared<HierarchicalBlockSparseMatrix<Treal> >();
				children[3]->parent = this;
				children[3]->set_params(get_params());
				children[3]->resize(nRows/2, nCols/2);

				std::vector<int> rows, cols;
				std::vector<Treal> vals;

				rows.resize(nRows/2);
				cols.resize(nRows/2);
				vals.resize(nRows/2);

				for(int i = 0; i < nRows/2; ++i){
					rows[i] = i;
					cols[i] = i;
					vals[i] = alpha;
				}

				children[3]->assign_from_vectors(rows, cols, vals);
			}


		}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x60, %rsp
movsd %xmm0, 0x18(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x39bc
testb %al, %al
jne 0x56fd
movl (%r14), %eax
cmpl 0x4(%r14), %eax
jne 0x571c
movq %rbx, %rdi
callq 0x3ad0
movl 0x10(%r14), %eax
movq %rsp, %rsi
movl %eax, (%rsi)
movq %rbx, %rdi
callq 0x3958
movl 0x8(%r14), %esi
movl 0xc(%r14), %edx
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x39e4
movq %r14, %rdi
callq 0x5a0a
testb %al, %al
je 0x5386
movq 0x70(%rbx), %rdi
movq 0x70(%r14), %rsi
movq 0x78(%r14), %rdx
subq %rsi, %rdx
callq 0x2120
movl (%rbx), %eax
leal 0x1(%rax), %ecx
movq 0x70(%rbx), %rdx
testl %eax, %eax
cmovlel %r15d, %eax
movsd 0x18(%rsp), %xmm1
subq $0x1, %rax
jb 0x56f0
movslq %r15d, %r15
movsd (%rdx,%r15,8), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rdx,%r15,8)
addl %ecx, %r15d
jmp 0x5364
cmpq $0x0, 0x38(%r14)
je 0x53c1
movq %rsp, %r15
movq %r15, %rdi
callq 0x68de
leaq 0x38(%rbx), %rdi
movq %r15, %rsi
callq 0x5a26
leaq 0x8(%rsp), %rdi
callq 0x5a54
movq 0x38(%rbx), %rdi
movq %rbx, 0x68(%rdi)
movq 0x38(%r14), %rsi
xorl %edx, %edx
callq 0x50a2
cmpq $0x0, 0x48(%r14)
je 0x53fc
movq %rsp, %r15
movq %r15, %rdi
callq 0x68de
leaq 0x48(%rbx), %rdi
movq %r15, %rsi
callq 0x5a26
leaq 0x8(%rsp), %rdi
callq 0x5a54
movq 0x48(%rbx), %rdi
movq %rbx, 0x68(%rdi)
movq 0x48(%r14), %rsi
xorl %edx, %edx
callq 0x50a2
leaq 0x28(%rbx), %r15
cmpq $0x0, 0x28(%r14)
movq 0x28(%rbx), %rax
pushq $0x2
popq %rbp
je 0x5453
testq %rax, %rax
jne 0x5738
movq %rsp, %r12
movq %r12, %rdi
callq 0x68de
movq %r15, %rdi
movq %r12, %rsi
callq 0x5a26
leaq 0x8(%rsp), %rdi
callq 0x5a54
movq 0x28(%rbx), %rdi
movq %rbx, 0x68(%rdi)
movq 0x28(%r14), %rsi
movsd 0x18(%rsp), %xmm0
callq 0x52cc
jmp 0x5579
testq %rax, %rax
jne 0x5770
movq %rsp, %r12
movq %r12, %rdi
callq 0x68de
movq %r15, %rdi
movq %r12, %rsi
callq 0x5a26
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x5a54
movq 0x28(%rbx), %rdi
movq %rbx, 0x68(%rdi)
movl 0x10(%rbx), %eax
movl %eax, -0x8(%r12)
movq %rsp, %r12
movq %r12, %rsi
callq 0x3958
movq 0x28(%rbx), %rdi
movl (%rbx), %eax
movl 0x4(%rbx), %ecx
cltd
idivl %ebp
movl %eax, %esi
movl %ecx, %eax
cltd
idivl %ebp
movl %eax, %edx
xorl %ecx, %ecx
callq 0x39e4
andq $0x0, 0x10(%r12)
xorpd %xmm0, %xmm0
andq $0x0, 0x50(%rsp)
movapd %xmm0, (%r12)
andq $0x0, 0x30(%rsp)
movapd %xmm0, 0x40(%rsp)
movapd %xmm0, 0x20(%rsp)
movl (%rbx), %eax
cltd
idivl %ebp
movslq %eax, %rsi
movq %rsp, %rdi
callq 0x74ae
movl (%rbx), %eax
cltd
idivl %ebp
movslq %eax, %rsi
leaq 0x40(%rsp), %rdi
callq 0x74ae
movl (%rbx), %eax
cltd
idivl %ebp
movslq %eax, %rsi
leaq 0x20(%rsp), %rdi
callq 0x57fc
movq (%rsp), %rcx
movq 0x40(%rsp), %rsi
movq 0x20(%rsp), %rdi
xorl %r8d, %r8d
movsd 0x18(%rsp), %xmm0
movl (%rbx), %eax
cltd
idivl %ebp
cltq
cmpq %rax, %r8
jge 0x5548
movl %r8d, (%rcx,%r8,4)
movl %r8d, (%rsi,%r8,4)
movsd %xmm0, (%rdi,%r8,8)
incq %r8
jmp 0x5529
movq (%r15), %rdi
movq %rsp, %rsi
leaq 0x40(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq 0x3d1c
leaq 0x20(%rsp), %rdi
callq 0x5c00
leaq 0x40(%rsp), %rdi
callq 0x5afc
movq %rsp, %rdi
callq 0x5afc
leaq 0x58(%rbx), %r15
cmpq $0x0, 0x58(%r14)
movq 0x58(%rbx), %rax
je 0x55cd
testq %rax, %rax
jne 0x5754
movq %rsp, %r12
movq %r12, %rdi
callq 0x68de
movq %r15, %rdi
movq %r12, %rsi
callq 0x5a26
leaq 0x8(%rsp), %rdi
callq 0x5a54
movq 0x58(%rbx), %rdi
movq %rbx, 0x68(%rdi)
movq 0x58(%r14), %rsi
movsd 0x18(%rsp), %xmm0
callq 0x52cc
jmp 0x56f0
testq %rax, %rax
jne 0x578c
movq %rsp, %r14
movq %r14, %rdi
callq 0x68de
movq %r15, %rdi
movq %r14, %rsi
callq 0x5a26
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x5a54
movq 0x58(%rbx), %rdi
movq %rbx, 0x68(%rdi)
movl 0x10(%rbx), %eax
movl %eax, -0x8(%r14)
movq %rsp, %r14
movq %r14, %rsi
callq 0x3958
movq 0x58(%rbx), %rdi
movl (%rbx), %eax
movl 0x4(%rbx), %ecx
cltd
idivl %ebp
movl %eax, %esi
movl %ecx, %eax
cltd
idivl %ebp
movl %eax, %edx
xorl %ecx, %ecx
callq 0x39e4
andq $0x0, 0x10(%r14)
xorpd %xmm0, %xmm0
andq $0x0, 0x50(%rsp)
movapd %xmm0, (%r14)
andq $0x0, 0x30(%rsp)
movapd %xmm0, 0x40(%rsp)
movapd %xmm0, 0x20(%rsp)
movl (%rbx), %eax
cltd
idivl %ebp
movslq %eax, %rsi
movq %rsp, %rdi
callq 0x74ae
movl (%rbx), %eax
cltd
idivl %ebp
movslq %eax, %rsi
leaq 0x40(%rsp), %rdi
callq 0x74ae
movl (%rbx), %eax
cltd
idivl %ebp
movslq %eax, %rsi
leaq 0x20(%rsp), %rdi
callq 0x57fc
movq (%rsp), %rcx
movq 0x40(%rsp), %rsi
movq 0x20(%rsp), %rdi
xorl %r8d, %r8d
movsd 0x18(%rsp), %xmm0
movl (%rbx), %eax
cltd
idivl %ebp
cltq
cmpq %rax, %r8
jge 0x56bf
movl %r8d, (%rcx,%r8,4)
movl %r8d, (%rsi,%r8,4)
movsd %xmm0, (%rdi,%r8,8)
incq %r8
jmp 0x56a0
movq (%r15), %rdi
movq %rsp, %rsi
leaq 0x40(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq 0x3d1c
leaq 0x20(%rsp), %rdi
callq 0x5c00
leaq 0x40(%rsp), %rdi
callq 0x5afc
movq %rsp, %rdi
callq 0x5afc
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x20a0
movq %rax, %r14
leaq 0x3a55(%rip), %rsi      # 0x9164
movq %rax, %rdi
callq 0x2050
jmp 0x57a6
pushq $0x10
popq %rdi
callq 0x20a0
movq %rax, %r14
leaq 0x3a8c(%rip), %rsi      # 0x91ba
movq %rax, %rdi
callq 0x2050
jmp 0x57a6
pushq $0x10
popq %rdi
callq 0x20a0
movq %rax, %r14
leaq 0x3acb(%rip), %rsi      # 0x9215
movq %rax, %rdi
callq 0x2050
jmp 0x57a6
pushq $0x10
popq %rdi
callq 0x20a0
movq %rax, %r14
leaq 0x3b06(%rip), %rsi      # 0x926c
movq %rax, %rdi
callq 0x2050
jmp 0x57a6
pushq $0x10
popq %rdi
callq 0x20a0
movq %rax, %r14
leaq 0x3a93(%rip), %rsi      # 0x9215
movq %rax, %rdi
callq 0x2050
jmp 0x57a6
pushq $0x10
popq %rdi
callq 0x20a0
movq %rax, %r14
leaq 0x3ace(%rip), %rsi      # 0x926c
movq %rax, %rdi
callq 0x2050
movq 0x7843(%rip), %rsi      # 0xcff0
movq 0x780c(%rip), %rdx      # 0xcfc0
movq %r14, %rdi
callq 0x21d0
jmp 0x57c6
jmp 0x57c6
jmp 0x57c6
jmp 0x57c6
jmp 0x57c6
movq %rax, %rbx
movq %r14, %rdi
callq 0x2100
jmp 0x57f4
jmp 0x57d5
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x5c00
leaq 0x40(%rsp), %rdi
callq 0x5afc
movq %rsp, %rdi
callq 0x5afc
movq %rbx, %rdi
callq 0x21f0