<commit_before>/*
   Copyright (c) 2009-2014, <NAME>
   All rights reserved.

   This file is part of Elemental and is under the BSD 2-Clause License, 
   which can be found in the LICENSE file in the root directory, or at 
   http://opensource.org/licenses/BSD-2-Clause
*/
// NOTE: It is possible to simply include "elemental.hpp" instead
#include "elemental-lite.hpp"
#include "elemental/matrices/Fourier.hpp"
#include "elemental/matrices/Uniform.hpp"
using namespace elem;

int 
main( int argc, char* argv[] )
{
    Initialize( argc, argv );

    try
    {
        const Int n = Input("--n","size of matrix",20);
        const Int numRows = Input("--numRows","num rows of submatrix",5);
        const Int numCols = Input("--numCols","num cols of submatrix",5);
        const bool display = Input("--display","display matrix?",true);
        const bool print = Input("--print","print matrix?",false);
        ProcessInput();
        PrintInputReport();

        if( numRows > n || numCols > n )
            LogicError("Submatrix too large");

        auto A = Fourier<double>( DefaultGrid(), n );
        if( display )
            Display( A, "Fourier Matrix" );
        if( print )
            Print( A, "Fourier matrix:" );

        // Get a consistent set of row and column indices (duplication is okay)
        std::vector<Int> rowInds(numRows), colInds(numCols);
        if( mpi::WorldRank() == 0 )
        {
            for( Int j=0; j<numRows; ++j )
                rowInds[j] = SampleUniform<Int>(0,n);
            for( Int j=0; j<numCols; ++j )
                colInds[j] = SampleUniform<Int>(0,n);
        }
        mpi::Broadcast( rowInds.data(), numRows, 0, mpi::COMM_WORLD );
        mpi::Broadcast( colInds.data(), numCols, 0, mpi::COMM_WORLD );
        if( mpi::WorldRank() == 0 && print )
        {
            std::cout << "rowInds: \n";
            for( Int j=0; j<numRows; ++j )
                std::cout << rowInds[j] << "\n";
            std::cout << "\n";
            std::cout << "colInds: \n";
            for( Int j=0; j<numRows; ++j )
                std::cout << colInds[j] << "\n";
            std::cout << std::endl;
        }
        
        auto ASub = A.Get( rowInds, colInds );
        if( display )
            Display( ASub, "ASub" );<commit_msg>Modifying Arbitrary submatrix manipulation driver<commit_after>/*
   Copyright (c) 2009-2014, <NAME>
   All rights reserved.

   This file is part of Elemental and is under the BSD 2-Clause License, 
   which can be found in the LICENSE file in the root directory, or at 
   http://opensource.org/licenses/BSD-2-Clause
*/
// NOTE: It is possible to simply include "elemental.hpp" instead
#include "elemental-lite.hpp"
#include "elemental/matrices/Fourier.hpp"
#include "elemental/matrices/Uniform.hpp"
using namespace elem;

int 
main( int argc, char* argv[] )
{
    Initialize( argc, argv );

    try
    {
        const Int n = Input("--n","size of matrix",20);
        const Int numRows = Input("--numRows","num rows of submatrix",5);
        const Int numCols = Input("--numCols","num cols of submatrix",5);
        const bool display = Input("--display","display matrix?",true);
        const bool print = Input("--print","print matrix?",false);
        ProcessInput();
        PrintInputReport();

        if( numRows > n || numCols > n )
            LogicError("Submatrix too large");

        auto A = Fourier<double>( DefaultGrid(), n );
        if( display )
            Display( A, "Fourier Matrix" );
        if( print )
            Print( A, "Fourier matrix:" );

        // Get a consistent set of row and column indices (duplication is okay)
        std::vector<Int> rowInds(numRows), colInds(numCols);
        if( mpi::WorldRank() == 0 )
        {
            for( Int j=0; j<numRows; ++j )
                rowInds[j] = SampleUniform<Int>(0,n);
            for( Int j=0; j<numCols; ++j )
                colInds[j] = SampleUniform<Int>(0,n);
        }
        mpi::Broadcast( rowInds.data(), numRows, 0, mpi::COMM_WORLD );
        mpi::Broadcast( colInds.data(), numCols, 0, mpi::COMM_WORLD );
        if( mpi::WorldRank() == 0 && print )
        {
            std::cout << "rowInds: \n";
            for( Int j=0; j<numRows; ++j )
                std::cout << rowInds[j] << "\n";
            std::cout << "\n";
            std::cout << "colInds: \n";
            for( Int j=0; j<numCols; ++j )
                std::cout << colInds[j] << "\n";
            std::cout << std::endl;
        }
        
        auto ASub = A.Get( rowInds, colInds );
        if( display )
            Display( ASub, "ASub" );
{'fraction_non_alphanumeric': 0.1516072980017376, 'fraction_numerical': 0.010425716768027803, 'mean_word_length': 2.130523453433039, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2199289', 'n_tokens_mistral': 1507, 'n_tokens_neox': 1438, 'n_words': 410}