From 5fcfa2b242f35ab3f4c9dc0e0bfacb6e7033022d Mon Sep 17 00:00:00 2001 From: Pierre Marchand Date: Mon, 5 Jun 2023 12:05:56 +0200 Subject: [PATCH] update CHANGELOG.md and python scripts --- .gitignore | 7 +++++ CHANGELOG.md | 25 ++++++++++----- tools/plot_cluster.py | 28 +++++++++-------- tools/plot_hmatrix.py | 71 ++++++++++++++++++++++++------------------- 4 files changed, 81 insertions(+), 50 deletions(-) diff --git a/.gitignore b/.gitignore index 77a1ba6f..00a54bb3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,10 @@ +# Dotfiles +.* +!.gitignore +!.clang-format +!.clang-tidy +!.devcontainer + # Compiled Object files *.slo *.lo diff --git a/CHANGELOG.md b/CHANGELOG.md index 402071c1..a1d7ee41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,14 +28,25 @@ All notable changes to this project will be documented in this file. ### Added -- `set_delay_dense_computation` to `HMatrix` +- The old implementation of `HMatrix` was mixing the distributed operations and compression via hierarchical matrices. This is fixed by replacing `HMatrix` by: + - `DistributedOperator` which contains a list of local operators and implements all the distributed operations, + - `VirtualLocalOperator` which is the interface local operators must satisfy, + - `LocalDenseMatrix` is an example of local operator consisting of a dense matrix `Matrix`, + - and `LocalHMatrix` which is an example of local operator consisting of a hierarchical matrix based on `HMatrix` (different from the previous `HMatrix`, see below). + ### Changed +- `HMatrix` is now a class representing a hierarchical matrix without distributed-memory parallelism (note that it can still use shared-memory parallelism): + - It inherits from `TreeNode`, and it provides the algebra related to hierchical matrices. + - The algorithms for building the block cluster tree is contained in `HMatrixTreeBuilder`. Users can provide their own "factory". +- `VirtualCluster` is removed and the clustering part of the library has been rewritten: + - `Cluster` now derives from `TreeNode`, whose template parameter corresponds to the precision of cluster nodes' radius and centre (previously only `double`). + - Standards recursive build algorithms are provided via `ClusterTreeBuilder`. Users can provide their own "factory". + - `ClusterTreeBuilder` is a class template and uses the policy pattern (a policy for computing direction, and another for splitting along the direction). + ### Fixed -- Fix const-correctness for g++ 4.8.5 -- ## [0.8.1] - 2023-05-26 ### Added @@ -60,8 +71,8 @@ All notable changes to this project will be documented in this file. ### Added - doxygen documentation -- mvprod_transp_global_to_global and mvprod_transp_local_to_local added to VirtualHMatrix -- getters for clusters in VirtualHMatrix +- mvprod_transp_global_to_global and mvprod_transp_local_to_local added to `VirtualHMatrix` +- getters for clusters in `VirtualHMatrix` - custom gmv in ddm ### Changed @@ -80,12 +91,12 @@ All notable changes to this project will be documented in this file. - Test for warnings coming from `include/htool/*` - Coverage added - Methods in ddm interface to get local numbering -- VirtualLowRankGenerator and VirtualAdmissibilityCondition added for better modularity +- `VirtualLowRankGenerator` and `VirtualAdmissibilityCondition` added for better modularity ### Changed - Remove unnecessary arguments in HMatrix and cluster interfaces -- MutliHMatrix deprecated for the moment (everything related to this in `htool/multi`) +- `MultiHMatrix` deprecated for the moment (everything related to this in `htool/multi`) ### Fixed diff --git a/tools/plot_cluster.py b/tools/plot_cluster.py index 06a9a6d7..4791f16e 100644 --- a/tools/plot_cluster.py +++ b/tools/plot_cluster.py @@ -1,25 +1,25 @@ import numpy as np -from mpl_toolkits.mplot3d import Axes3D +from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import matplotlib.colors as colors import pandas as pd import argparse parser = argparse.ArgumentParser() -parser.add_argument("--inputfile",type=str) -parser.add_argument("--show",type=int,choices=[0,1],default=1) -parser.add_argument("--depth",type=int,default=1) -parser.add_argument("--save",type=str,default="") +parser.add_argument("--inputfile", type=str) +parser.add_argument("--show", type=int, choices=[0, 1], default=1) +parser.add_argument("--depth", type=int, default=1) +parser.add_argument("--save", type=str, default="") args = parser.parse_args() inputfile = args.inputfile depth = args.depth # First Data -data = (pd.read_csv(inputfile,header=None)).T +data = (pd.read_csv(inputfile, header=None)).T header = data.iloc[0] print(header) -data =data[1:] +data = data[1:] data.columns = header @@ -31,14 +31,18 @@ fig = plt.figure() ax = fig.add_subplot(111, projection='3d') -ax.scatter(data["x_0"].tolist(), data["x_1"].tolist(), data["x_2"].tolist(),c=colormap(norm(data[str(depth)].tolist())), marker='o') - +if "x_2" in data.columns: + ax.scatter(data["x_0"].tolist(), data["x_1"].tolist(), data["x_2"].tolist( + ), c=colormap(norm(data[str(depth)].tolist())), marker='o') +else: + ax.scatter(data["x_0"].tolist(), data["x_1"].tolist(), + c=colormap(norm(data[str(depth)].tolist())), marker='o') # Output if args.show: plt.show() -if args.save!="": - fig.savefig(args.save,bbox_inches = 'tight', - pad_inches = 0) \ No newline at end of file +if args.save != "": + fig.savefig(args.save, bbox_inches='tight', + pad_inches=0) diff --git a/tools/plot_hmatrix.py b/tools/plot_hmatrix.py index 7f7d15e7..fbb72737 100644 --- a/tools/plot_hmatrix.py +++ b/tools/plot_hmatrix.py @@ -6,69 +6,78 @@ import argparse parser = argparse.ArgumentParser() -parser.add_argument("--inputfile",type=str) -parser.add_argument("--sizeWorld",type=int,default=1) -parser.add_argument("--show",type=int,choices=[0,1],default=1) -parser.add_argument("--save",type=str,default="") +parser.add_argument("--inputfile", type=str) +parser.add_argument("--show", type=int, choices=[0, 1], default=1) +parser.add_argument("--save", type=str, default="") args = parser.parse_args() inputfile = args.inputfile -sizeWorld = args.sizeWorld # First Data -size = pd.read_csv(inputfile+"_0.csv",nrows=1,header=None) +size = pd.read_csv(inputfile, nrows=1, header=None) nr = size.iloc[0][0] nc = size.iloc[0][1] -matrix = np.zeros((nr,nc)) +matrix = np.zeros((nr, nc)) # Figure -fig, axes = plt.subplots(1,1) +fig, axes = plt.subplots(1, 1) axes.xaxis.tick_top() plt.imshow(matrix) # Issue: there a shift of one pixel along the y-axis... -shift = axes.transData.transform([(0,0), (1,1)]) -shift = shift[1,1] - shift[0,1] # 1 unit in display coords +shift = axes.transData.transform([(0, 0), (1, 1)]) +shift = shift[1, 1] - shift[0, 1] # 1 unit in display coords shift = 0 # 1/shift # 1 pixel in display coords # Loop -for i in range(0,sizeWorld): - print(i) - data = pd.read_csv(inputfile+"_"+str(i)+".csv",skiprows=1,header=None) - - for index, row in data.iterrows(): - matrix[np.ix_(range(row[0],row[0]+row[1]),range(row[2],row[2]+row[3]))]=row[4] - rect = patches.Rectangle((row[2]-0.5,row[0]-0.5+shift),row[3],row[1],linewidth=0.75,edgecolor='k',facecolor='none') - axes.add_patch(rect) - if row[4]>=0 and row[3]/float(nc)>0.05 and row[1]/float(nc)>0.05: - axes.annotate(row[4],(row[2]+row[3]/2.,row[0]+row[1]/2.),color="white",size=10, va='center', ha='center') - - - +data = pd.read_csv(inputfile, skiprows=1, header=None) +for index, row in data.iterrows(): + matrix[ + np.ix_(range(row[0], row[0] + row[1]), range(row[2], row[2] + row[3])) + ] = row[4] + rect = patches.Rectangle( + (row[2] - 0.5, row[0] - 0.5 + shift), + row[3], + row[1], + linewidth=0.75, + edgecolor="k", + facecolor="none", + ) + axes.add_patch(rect) + if row[4] >= 0 and row[3] / float(nc) > 0.05 and row[1] / float(nc) > 0.05: + axes.annotate( + row[4], + (row[2] + row[3] / 2.0, row[0] + row[1] / 2.0), + color="white", + size=10, + va="center", + ha="center", + ) # Colormap def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100): new_cmap = colors.LinearSegmentedColormap.from_list( - 'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval), - cmap(np.linspace(minval, maxval, n))) + "trunc({n},{a:.2f},{b:.2f})".format(n=cmap.name, a=minval, b=maxval), + cmap(np.linspace(minval, maxval, n)), + ) return new_cmap -cmap = plt.get_cmap('YlGn') + +cmap = plt.get_cmap("YlGn") new_cmap = truncate_colormap(cmap, 0.4, 1) # Plot -matrix =np.ma.masked_where(0>matrix,matrix) +matrix = np.ma.masked_where(0 > matrix, matrix) new_cmap.set_bad(color="red") -plt.imshow(matrix,cmap=new_cmap,vmin=0, vmax=10) +plt.imshow(matrix, cmap=new_cmap, vmin=0, vmax=10) # Output if args.show: plt.show() -if args.save!="": - fig.savefig(args.save,bbox_inches = 'tight', - pad_inches = 0) \ No newline at end of file +if args.save != "": + fig.savefig(args.save, bbox_inches="tight", pad_inches=0)