<commit_before>//
// Created by max on 22/04/16.
//

#include "CrankNicholson1D.hpp"

__host__ __device__ double Pot(double x,double t){
    return 2 / sqrt(1 + x * x);
}
__global__ void PrepRHS(double* v) {
    // This function preperates the Right hand side of the CN algorithm

}

__global__ void PrepLHS(double* d1, double* d2, double* d3, size_t nx, double t) {
    // This function preperates the Left hand side of the CN algorithm
}

CrankNicholson1D::CrankNicholson1D() : nx(0),
                                       nt(0) {

}

CrankNicholson1D::CrankNicholson1D(Params1D& p):
                                    nx(p.getnx()),
                                    nt(p.getnt()),
                                    params(&p),
                                    frames(nx*TCHUNK){

}

CrankNicholson1D::~CrankNicholson1D() { }
void CrankNicholson1D::preprt() {

}

void CrankNicholson1D::genframes(const vector<complex<double>>& v) {
    // first we should prepare Host and device vectors
    cuDoubleComplex* vecl = (cuDoubleComplex*) malloc(sizeof(cuDoubleComplex) * nx);
    cuDoubleComplex* vecr = (cuDoubleComplex*) malloc(sizeof(cuDoubleComplex) * nx);
    cuDoubleComplex* dev_vecl;
    cuDoubleComplex* dev_vecr;

    // Initialize the cuSparse context
    cusparseHandle_t h;
    cusparseStatus_t status= cusparseCreate(&h);
    // check for errors!
    if(status != CUSPARSE_STATUS_SUCCESS )
       DEBUG("Init failed!");

    //  after given an initial state, we initialize out internally used cuDoubleComplex vectors
    for(auto i = v.begin(); i != v.end(); ++i) {
        // the first vector is always on the right hand side first since
        // it's psi(t=0)
        auto j = distance( i, v.begin());
        vecr[j].x = i->real();
        vecr[j].y = i->imag();
    }

    // Initialize Cuda Memory/cusparse
    cudaMalloc((void**) dev_vecl, sizeof(cuDoubleComplex)*nx);
    cudaMalloc((void**) dev_vecr, sizeof(cuDoubleComplex)*nx);
    cudaMemcpy(dev_vecr,vecr,sizeof(cuDoubleComplex)*nx,cudaMemcpyHostToDevice);

    // Next on we initialize the 6 Arrays the the triangular Matrix
    // Only preperation of left hand side is necessary since the
    // right hand side can be calculated more efficiently
    cuDoubleComplex* opl1 = (cuDoubleComplex*) malloc(sizeof(cuDoubleComplex) * nx);
    cuDoubleComplex* opl2 = (cuDoubleComplex*) malloc(sizeof(cuDoubleComplex) * nx);
    cuDoubleComplex* opl3 = (cuDoubleComplex*) malloc(sizeof(cuDoubleComplex) * nx);
    cuDoubleComplex* opl1_dev;
    cuDoubleComplex* opl2_dev;
    cuDoubleComplex* opl3_dev;
    cudaMalloc((void**) &opl1_dev, sizeof(cuDoubleComplex) * nx);
    cudaMalloc((void**) &opl2_dev, sizeof(cuDoubleComplex) * nx);
    cudaMalloc((void**) &opl3_dev, sizeof(cuDoubleComplex) * nx);
    

}<commit_msg>Added stuff to CN<commit_after>//
// Created by max on 22/04/16.
//

#include "CrankNicholson1D.hpp"

__host__ __device__ double Pot(double x,double t){
    return 2 / sqrt(1 + x * x);
}
__global__ void PrepRHS(double* vecr) {
    // This function preperates the Right hand side of the CN algorithm

}

__global__ void PrepLHS(double* d1, double* d2, double* d3, size_t nx, double t) {
    // This function preperates the Left hand side of the CN algorithm
}

CrankNicholson1D::CrankNicholson1D() : nx(0),
                                       nt(0) {

}

CrankNicholson1D::CrankNicholson1D(Params1D& p):
                                    nx(p.getnx()),
                                    nt(p.getnt()),
                                    params(&p),
                                    frames(nx*TCHUNK){

}

CrankNicholson1D::~CrankNicholson1D() { }

void CrankNicholson1D::preprt(double* vecr_dev,
                              double* opl1_dev, double* opl2_dev, double* opl3_dev) {
    // The preperation routine is here to
    // Call the preperation Kernels!
    preprt<<<nx,4>>>(vecr_dev);
    5

}

void CrankNichsolson1D::memrt(){

}

void CrankNicholson1D::genframes(const vector<complex<double>>& v) {
    // first we should prepare Host and device vectors
    cuDoubleComplex* vecl = (cuDoubleComplex*) malloc(sizeof(cuDoubleComplex) * nx);
    cuDoubleComplex* vecr = (cuDoubleComplex*) malloc(sizeof(cuDoubleComplex) * nx);
    cuDoubleComplex* dev_vecl;
    cuDoubleComplex* dev_vecr;

    // Initialize the cuSparse context
    cusparseHandle_t h;
    cusparseStatus_t status= cusparseCreate(&h);
    // check for errors!
    if(status != CUSPARSE_STATUS_SUCCESS )
       DEBUG("Init failed!");

    //  after given an initial state, we initialize out internally used cuDoubleComplex vectors
    for(auto i = v.begin(); i != v.end(); ++i) {
        // the first vector is always on the right hand side first since
        // it's psi(t=0)
        auto j = distance( i, v.begin());
        vecr[j].x = i->real();
        vecr[j].y = i->imag();
    }

    // Initialize Cuda Memory/cusparse
    cudaMalloc((void**) dev_vecl, sizeof(cuDoubleComplex)*nx);
    cudaMalloc((void**) dev_vecr, sizeof(cuDoubleComplex)*nx);
    cudaMemcpy(dev_vecr,vecr,sizeof(cuDoubleComplex)*nx,cudaMemcpyHostToDevice);

    // Next on we initialize the 6 Arrays the the triangular Matrix
    // Only preperation of left hand side is necessary since the
    // right hand side can be calculated more efficiently
    cuDoubleComplex* opl1 = (cuDoubleComplex*) malloc(sizeof(cuDoubleComplex) * nx);
    cuDoubleComplex* opl2 = (cuDoubleComplex*) malloc(sizeof(cuDoubleComplex) * nx);
    cuDoubleComplex* opl3 = (cuDoubleComplex*) malloc(sizeof(cuDoubleComplex) * nx);
    cuDoubleComplex* opl1_dev;
    cuDoubleComplex* opl2_dev;
    cuDoubleComplex* opl3_dev;
    cudaMalloc((void**) &opl1_dev, sizeof(cuDoubleComplex) * nx);
    cudaMalloc((void**) &opl2_dev, sizeof(cuDoubleComplex) * nx);
    cudaMalloc((void**) &opl3_dev, sizeof(cuDoubleComplex) * nx);


}
{'fraction_non_alphanumeric': 0.1167235494880546, 'fraction_numerical': 0.012627986348122866, 'mean_word_length': 2.9574611748818365, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2401818', 'n_tokens_mistral': 1985, 'n_tokens_neox': 1899, 'n_words': 472}