// File: lipiji[P]PG_DEEP/deep.cpp
// Function: RBM::RBM(int, int, int, double**, double*, double*, double, double)
RBM::RBM(int N, int n_f, int n_h, double **w, double *hb, double *vb, double lbd, double mmt)
{
    n_samples = N;
    n_visible = n_f;
    n_hidden = n_h;
    error = 0.0;
    lamda = lbd;
    momentum = mmt;

    if(w == NULL)
    {
        W = new double*[n_hidden];
        for(int i=0; i<n_hidden; i++)
            W[i] = new double[n_visible];
        for(int i=0; i<n_hidden; i++)
            for(int j=0; j<n_visible; j++)
                W[i][j] = sample_from_gaussian(0, 0.01);
    }
    else
    {
        W = w;
    }

    if(hb == NULL)
    {
        hbias = new double[n_hidden];
        for(int i=0; i<n_hidden; i++)
            hbias[i] = 0;
    }
    else
        hbias = hb;

    if(vb == NULL)
    {
        vbias = new double[n_visible];
        for(int i=0; i<n_visible; i++)
            vbias[i] = 0;
    }
    else
        vbias = vb;


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movsd %xmm0, -0x30(%rbp)
movsd %xmm1, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0xc(%rbp), %ecx
movl %ecx, (%rax)
movl -0x10(%rbp), %ecx
movl %ecx, 0x4(%rax)
movl -0x14(%rbp), %ecx
movl %ecx, 0x8(%rax)
xorps %xmm0, %xmm0
movsd %xmm0, 0x28(%rax)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, 0x30(%rax)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, 0x38(%rax)
cmpq $0x0, -0x20(%rbp)
jne 0x5d52
movq -0x58(%rbp), %rax
movslq 0x8(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, -0x3c(%rbp)
movq -0x58(%rbp), %rcx
movl -0x3c(%rbp), %eax
cmpl 0x8(%rcx), %eax
jge 0x5ce9
movq -0x58(%rbp), %rax
movslq 0x4(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rdx
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x5c96
movl $0x0, -0x40(%rbp)
movq -0x58(%rbp), %rcx
movl -0x40(%rbp), %eax
cmpl 0x8(%rcx), %eax
jge 0x5d50
movl $0x0, -0x44(%rbp)
movq -0x58(%rbp), %rcx
movl -0x44(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x5d43
xorps %xmm0, %xmm0
movsd 0x53b6(%rip), %xmm1     # 0xb0d0
callq 0x47d0
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x44(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x5d03
jmp 0x5d45
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x5cf0
jmp 0x5d5e
movq -0x58(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rcx, 0x10(%rax)
cmpq $0x0, -0x28(%rbp)
jne 0x5dcd
movq -0x58(%rbp), %rax
movslq 0x8(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x18(%rax)
movl $0x0, -0x48(%rbp)
movq -0x58(%rbp), %rcx
movl -0x48(%rbp), %eax
cmpl 0x8(%rcx), %eax
jge 0x5dcb
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x48(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x5da0
jmp 0x5dd9
movq -0x58(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, 0x18(%rax)
cmpq $0x0, 0x10(%rbp)
jne 0x5e48
movq -0x58(%rbp), %rax
movslq 0x4(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x20(%rax)
movl $0x0, -0x4c(%rbp)
movq -0x58(%rbp), %rcx
movl -0x4c(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x5e46
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x4c(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x5e1b
jmp 0x5e54
movq -0x58(%rbp), %rax
movq 0x10(%rbp), %rcx
movq %rcx, 0x20(%rax)
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)