// File: /workspace/github_cpp_makefile_star2_O2/btbujiangjun[P]abcdl/src/algebra/MatrixAlgebra.cpp
// Function: abcdl::algebra::Matrix<unsigned long>::mean(abcdl::algebra::Axis_type) const
Matrix<real> Matrix<T>::mean(Axis_type type) const{
    size_t size = 0;
    real count = 0;
    size_t mean_row = 0;
    size_t mean_col = 0;
    if(type == Axis_type::ROW){
        size = _rows;
        count = _cols;
        mean_row = _rows;
        mean_col = 1;
    }else{
        size = _cols;
        count = _rows;
        mean_row = 1;
        mean_col = _cols;
    }
    real* data = new real[size];

    if(type == Axis_type::ROW){
        for(size_t i = 0; i < _rows; i++){
            real total = 0;
            for(size_t j = 0; j < _cols; j++){
                total += get_data(i, j);
            }
            data[i] = total/count;
        }
    }else if(type == Axis_type::COL){
        for(size_t i = 0; i < _cols; i++){
            real total = 0;
            for(size_t j = 0; j < _rows; j++){
                total += get_data(j, i);
            }
            data[i] =  total/count;
        }
    }

    Matrix<real> mean_mat;
    mean_mat.set_shallow_data(data, mean_row, mean_col);
    return mean_mat;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %rbx
testl %edx, %edx
je 0x25cc5
movq 0x8(%r12), %r14
pushq $0x1
popq %rax
movq %rax, 0x10(%rsp)
movq %r12, %rcx
movq %r14, %rax
jmp 0x25cd7
movq (%r12), %rax
leaq 0x8(%r12), %rcx
pushq $0x1
popq %r14
movq %rax, 0x10(%rsp)
movq (%rcx), %rcx
testq %rcx, %rcx
js 0x25ce6
cvtsi2ss %rcx, %xmm0
jmp 0x25cfb
movq %rcx, %rdx
shrq %rdx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
movss %xmm0, 0x8(%rsp)
movq %rax, %rcx
shrq $0x3e, %rcx
shlq $0x2, %rax
xorl %edi, %edi
negq %rcx
sbbq %rdi, %rdi
orq %rax, %rdi
callq 0x9030
movq %rax, %r13
testl %ebp, %ebp
je 0x25da1
cmpl $0x1, %ebp
jne 0x25e12
xorl %ebp, %ebp
cmpq 0x8(%r12), %rbp
jae 0x25e12
xorps %xmm0, %xmm0
xorl %r15d, %r15d
cmpq (%r12), %r15
jae 0x25d8f
movss %xmm0, 0xc(%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x1a544
movq (%rax), %rax
testq %rax, %rax
js 0x25d68
cvtsi2ss %rax, %xmm0
jmp 0x25d7d
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
movss 0xc(%rsp), %xmm1
addss %xmm0, %xmm1
movaps %xmm1, %xmm0
incq %r15
jmp 0x25d3f
divss 0x8(%rsp), %xmm0
movss %xmm0, (%r13,%rbp,4)
incq %rbp
jmp 0x25d2e
xorl %ebp, %ebp
cmpq (%r12), %rbp
jae 0x25e12
xorps %xmm0, %xmm0
xorl %r15d, %r15d
cmpq 0x8(%r12), %r15
jae 0x25e00
movss %xmm0, 0xc(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x1a544
movq (%rax), %rax
testq %rax, %rax
js 0x25dd9
cvtsi2ss %rax, %xmm0
jmp 0x25dee
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
movss 0xc(%rsp), %xmm1
addss %xmm0, %xmm1
movaps %xmm1, %xmm0
incq %r15
jmp 0x25daf
divss 0x8(%rsp), %xmm0
movss %xmm0, (%r13,%rbp,4)
incq %rbp
jmp 0x25da3
movq %rbx, %rdi
callq 0x17dac
movq %rbx, %rdi
movq %r13, %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rcx
callq 0x1823e
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x17fd6
movq %r14, %rdi
callq 0x95e0