#!/usr/bin/env python3

# This file is part of ParTI!.
#
# ParTI! is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# ParTI! is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with ParTI!.
# If not, see <http://www.gnu.org/licenses/>.

import math
import random
import sys
import numpy


# 生成稀疏度不同，规模不同的随机矩阵
rows = 100
cols = 100
degree = 0.8

def generalmat(rows, cols, degree):
    nonzeros_num = int(rows*cols*degree)
    index_array = random.sample(range(rows*cols), nonzeros_num)
    index_array.sort()

    # write file
    output = 'exp_gemat/m%d_%d_%.4f.tns' %(rows,cols,degree)
    f = open(output, 'w')
    f.write('%d %d %d' % (rows,cols,nonzeros_num))
    f.write('\n')
    for i in range(nonzeros_num):
        value = random.random()
        f.write('%d %d %f \n' % (int(index_array[i]/cols)+1, index_array[i]%cols+1, value))



mat_num = 1000

for i in range(mat_num):
    degree_list = [random.uniform(0.001,0.01), random.uniform(0.01,0.1), random.uniform(0.1,0.3)]
    size_list = [random.randint(50,150),random.randint(150,300),random.randint(300,500),random.randint(500,800),random.randint(800,1000),random.randint(1000,1500),random.randint(1500,2500),random.randint(2500,5000)]
    rows = size_list[i%len(size_list)]
    cols = random.choice(size_list)
    degree = random.choice(degree_list)
    generalmat(rows, cols, degree)
    nonzeros_num = int(rows*cols*degree)
    print("%d(%d %d %d) general success!" % (i,rows,cols,nonzeros_num))


#!/usr/bin/env python3

# This file is part of ParTI!.
#
# ParTI! is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# ParTI! is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with ParTI!.
# If not, see <http://www.gnu.org/licenses/>.

import math
import random
import sys
import numpy


# 生成稀疏度不同，规模不同的随机矩阵
rows = 100
cols = 100
degree = 0.8

def generalmat(rows, cols, degree):
    nonzeros_num = int(rows*cols*degree)
    index_array = random.sample(range(rows*cols), nonzeros_num)
    index_array.sort()

    # write file
    output = 'exp_gemat/m%d_%d_%.4f.tns' %(rows,cols,degree)
    f = open(output, 'w')
    f.write('%d %d %d' % (rows,cols,nonzeros_num))
    f.write('\n')
    for i in range(nonzeros_num):
        value = random.random()
        f.write('%d %d %f \n' % (int(index_array[i]/cols)+1, index_array[i]%cols+1, value))



mat_num = 1000

for i in range(mat_num):
    degree_list = [random.uniform(0.001,0.01), random.uniform(0.01,0.1), random.uniform(0.1,0.3)]
    size_list = [random.randint(50,150),random.randint(150,300),random.randint(300,500),random.randint(500,800),random.randint(800,1000),random.randint(1000,1500),random.randint(1500,2500),random.randint(2500,5000)]
    rows = size_list[i%len(size_list)]
    cols = random.choice(size_list)
    degree = random.choice(degree_list)
    generalmat(rows, cols, degree)
    nonzeros_num = int(rows*cols*degree)
    print("%d(%d %d %d) general success!" % (i,rows,cols,nonzeros_num))


#!/usr/bin/env python3 # This file is part of ParTI!. # # ParTI! is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation, either version 3 of # the License, or (at your option) any later version. # # ParTI! is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the # GNU General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with ParTI!. # If not, see <http://www.gnu.org/licenses/>. # 生成稀疏度不同，规模不同的随机矩阵 # write file