Пример #1
0
            public void on_pre_save(plib.state_manager_t manager)
            {
                throw new emu_unimplemented();
#if false
                plib::unused_var(manager);
                m_qsize = this->size();
                for (std::size_t i = 0; i < m_qsize; i++)
                {
                    m_times[i]   = this->listptr()[i].exec_time().as_raw();
                    m_net_ids[i] = m_get_id(this->listptr()[i].object());
Пример #2
0
        public static void cache_clear()
        {
            //throw new emu_unimplemented();
#if false
            // clear call cache entries
            std::lock_guard <std::mutex> guard(s_cache_mutex);

            for (std::size_t cachenum = 0; cachenum < s_cache.size(); s_cache[cachenum++].reset())
            {
            }
#endif
        }
Пример #3
0
        static string catremainder(std.vector <string> elems, size_t start, string sep)
        {
            throw new emu_unimplemented();
#if false
            pstring ret("");

            for (std::size_t i = start; i < elems.size(); i++)
            {
                ret += elems[i];
                ret += sep;
            }
            return(ret);
#endif
        }
Пример #4
0
        //~pmatrix2d()


        void resize(pmatrix2d_size_type N, pmatrix2d_size_type M)
        {
            throw new emu_unimplemented();
#if false
            gsl_Expects(N > 0);
            gsl_Expects(M > 0);
            if (m_v != nullptr)
            {
                for (std::size_t i = 0; i < N * m_stride; i++)
                {
                    (&m_v[i])->~T();
                }
                m_a.deallocate(m_v, N * m_stride);
            }
            m_N      = N;
            m_M      = M;
            m_stride = ((M + stride_size - 1) / stride_size) * stride_size;
            m_v      = m_a.allocate(N * m_stride);
            for (std::size_t i = 0; i < N * m_stride; i++)
            {
                ::new(&m_v[i]) T();
            }
Пример #5
0
        SRes read(void *data, std::size_t&size)
        {
            if (!osdfile)
            {
                osd_printf_error("un7z: called CSzFile::read without file\n");
                return(SZ_ERROR_READ);
            }

            if (!size)
            {
                return(SZ_OK);
            }

            // TODO: this casts a size_t to a uint32_t, so it will fail if >=4GB is requested at once (need a loop)
            std::uint32_t read_length(0);

            auto const err = osdfile->read(data, currfpos, size, read_length);

            size      = read_length;
            currfpos += read_length;

            return((osd_file::error::NONE == err) ? SZ_OK : SZ_ERROR_READ);
        }
Пример #6
0
            //template <typename FT, int SIZE>
            void generate_code(out string strm)  //void matrix_solver_GCR_t<FT, SIZE>::generate_code(plib::putf8_fmt_writer &strm)
            {
                strm = "";

                size_t iN       = this.size();
                string fptype   = fp_constants_double.name();   //pstring fptype(fp_constants<FT>::name());
                string fpsuffix = fp_constants_double.suffix(); //pstring fpsuffix(fp_constants<FT>::suffix());

                // avoid unused variable warnings
                strm += string.Format("\tplib::unused_var({0});\n", "cnV");

                for (size_t i = 0; i < mat.nz_num; i++)
                {
                    strm += string.Format("\t{0} m_A{1}(0.0);\n", fptype, i, i);
                }

                for (size_t k = 0; k < iN; k++)
                {
                    var net = this.m_terms[k];

                    // FIXME: gonn, gtn and Idr - which float types should they have?

                    //auto gtot_t = std::accumulate(gt, gt + term_count, plib::constants<FT>::zero());
                    //*tcr_r[railstart] = static_cast<FT>(gtot_t); //mat.A[mat.diag[k]] += gtot_t;

                    var pd = this.m_mat_ptr.op(k)[net.railstart()] - new Pointer <FT>(this.mat.A, 0);  //auto pd = this->m_mat_ptr[k][net.railstart()] - &this->mat.A[0];
#if false
                    string terms = new plib.pfmt("m_A{0} = gt[{1}]").op(pd.Offset, this.m_gtn.didx(k, 0));
                    for (size_t i = 1; i < net.count(); i++)
                    {
                        terms += new plib.pfmt(" + gt[{0}]").op(this.m_gtn.didx(k, i));
                    }

                    strm += string.Format("\t{0};\n", terms);
#else
                    for (size_t i = 0; i < net.count(); i++)
                    {
                        strm += string.Format("\tm_A{0} += gt[{1}];\n", pd, this.m_gtn.didx(k, i));
                    }
#endif

                    //for (std::size_t i = 0; i < railstart; i++)
                    //  *tcr_r[i]       += static_cast<FT>(go[i]);

                    for (size_t i = 0; i < net.railstart(); i++)
                    {
                        var p = this.m_mat_ptr.op(k)[i] - new Pointer <FT>(this.mat.A, 0);  //auto p = this->m_mat_ptr[k][i] - &this->mat.A[0];
                        strm += string.Format("\tm_A{0} += go[{1}];\n", p, this.m_gonn.didx(k, i));
                    }

#if false
                    //auto RHS_t(std::accumulate(Idr, Idr + term_count, plib::constants<FT>::zero()));

                    terms = new plib.pfmt("{0} RHS{1} = Idr[{2}]").op(fptype, k, this.m_Idrn.didx(k, 0));
                    for (size_t i = 1; i < net.count(); i++)
                    {
                        terms += new plib.pfmt(" + Idr[{0}]").op(this.m_Idrn.didx(k, i));
                    }
                    //for (std::size_t i = railstart; i < term_count; i++)
                    //  RHS_t +=  (- go[i]) * *cnV[i];

                    for (size_t i = net.railstart(); i < net.count(); i++)
                    {
                        terms += new plib.pfmt(" - go[{0}] * *cnV[{1}]").op(this.m_gonn.didx(k, i), this.m_connected_net_Vn.didx(k, i));
                    }

                    strm += string.Format("\t{0};\n", terms);
#else
                    //auto RHS_t(std::accumulate(Idr, Idr + term_count, plib::constants<FT>::zero()));
                    strm += string.Format("\t{0} RHS{1} = Idr[{2}];\n", fptype, k, this.m_Idrn.didx(k, 0));
                    for (size_t i = 1; i < net.count(); i++)
                    {
                        strm += string.Format("\tRHS{0} += Idr[{1}];\n", k, this.m_Idrn.didx(k, i));
                    }
                    //for (std::size_t i = railstart; i < term_count; i++)
                    //  RHS_t +=  (- go[i]) * *cnV[i];

                    for (size_t i = net.railstart(); i < net.count(); i++)
                    {
                        strm += string.Format("\tRHS{0} -= go[{1}] * *cnV[{2}];\n", k, this.m_gonn.didx(k, i), this.m_connected_net_Vn.didx(k, i));
                    }
#endif
                }

                for (size_t i = 0; i < iN - 1; i++)
                {
                    //const auto &nzbd = this->m_terms[i].m_nzbd;
                    var nzbd       = mat.nzbd(i);
                    var nzbd_count = mat.nzbd_count(i);

                    if (nzbd_count > 0)
                    {
                        size_t pi = mat.diag[i];

                        //const FT f = 1.0 / m_A[pi++];
                        strm += string.Format("\tconst {0} f{1} = 1.0{2} / m_A{3};\n", fptype, i, fpsuffix, pi);
                        pi++;
                        size_t piie = mat.row_idx[i + 1];

                        //for (auto & j : nzbd)
                        for (size_t jj = 0; jj < nzbd_count; jj++)
                        {
                            size_t j = nzbd[jj];

                            // proceed to column i
                            size_t pj = mat.row_idx[j];

                            while (mat.col_idx[pj] < i)
                            {
                                pj++;
                            }

                            //const FT f1 = - m_A[pj++] * f;
                            strm += string.Format("\tconst {0} f{1}_{2} = -f{3} * m_A{4};\n", fptype, i, j, i, pj);
                            pj++;

                            // subtract row i from j
                            for (size_t pii = pi; pii < piie;)
                            {
                                while (mat.col_idx[pj] < mat.col_idx[pii])
                                {
                                    pj++;
                                }
                                //m_A[pj++] += m_A[pii++] * f1;
                                strm += string.Format("\tm_A{0} += m_A{1} * f{2}_{3};\n", pj, pii, i, j);
                                pj++; pii++;
                            }
                            //RHS[j] += f1 * RHS[i];
                            strm += string.Format("\tRHS{0} += f{1}_{2} * RHS{3};\n", j, i, j, i);
                        }
                    }
                }

                //new_V[iN - 1] = RHS[iN - 1] / mat.A[mat.diag[iN - 1]];
                strm += string.Format("\tV[{0}] = RHS{1} / m_A{2};\n", iN - 1, iN - 1, mat.diag[iN - 1]);
                for (size_t j = iN - 1; j-- > 0;)
                {
#if true
                    strm += string.Format("\t{0} tmp{1} = 0.0{2};\n", fptype, j, fpsuffix);
                    size_t e = mat.row_idx[j + 1];
                    for (size_t pk = (size_t)mat.diag[j] + 1; pk < e; pk++)
                    {
                        strm += string.Format("\ttmp{0} += m_A{1} * V[{2}];\n", j, pk, mat.col_idx[pk]);
                    }
                    strm += string.Format("\tV[{0}] = (RHS{0} - tmp{0}) / m_A{3};\n", j, j, j, mat.diag[j]);
#else
                    pstring           tmp;
                    const std::size_t e = mat.row_idx[j + 1];
                    for (std::size_t pk = mat.diag[j] + 1; pk < e; pk++)
                    {
                        tmp = tmp + plib::pfmt(" + m_A{2} * V[{3}]")(j, pk, mat.col_idx[pk]);
                    }
                    if (tmp.empty())
                    {
                        strm("\tV[{1}] = RHS{1} / m_A{2};\n", j, mat.diag[j]);
                    }
                    else
                    {
                        //strm("\tconst {1} tmp{2} = {3};\n", fptype, j, tmp.substr(3));
                        //strm("\tV[{1}] = (RHS{1} - tmp{1}) / m_A{2};\n", j, mat.diag[j]);
                        strm("\tV[{1}] = (RHS{1} - ({2})) / m_A{3};\n", j, tmp.substr(3), mat.diag[j]);
                    }
#endif
                }
            }