## private key – Is there a CUDA binary to convert a brainwallet string to a BTC address?

I am looking for a CUDA program which will take a single argument, a brainwallet password, and output a BTC address. After reading through several threads on how to convert passwords to public keys, and public keys to addresses, I figured there must already be something that does this.

Any suggestions welcome. Thanks.

## c++ – LeetCode 894: All Possible Full Binary Trees

I’m posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time!

### Problem

A full binary tree is a binary tree where each node has exactly 0 or 2
children.

Return a list of all possible full binary trees with N nodes. Each
element of the answer is the root node of one possible tree.

Each node of each tree in the answer must have `node.val = 0`.

You may return the final list of trees in any order.

### Example 1:

Input: 7

``````Output: (
(0,0,0,null,null,0,0,null,null,0,0),
(0,0,0,null,null,0,0,0,0),
(0,0,0,0,0,0,0),
(0,0,0,0,0,null,null,null,null,0,0),
(0,0,0,0,0,null,null,0,0)
)

``````

### Note:

`1 <= N <= 20`

### Code

``````#include <vector>

class Solution {
public:
static TreeNode *clone_tree(const TreeNode *node) {
TreeNode *root = new TreeNode(0);
root->left = (node->left) ? clone_tree(node->left) : nullptr;
root->right = (node->right) ? clone_tree(node->right) : nullptr;
return root;
}

static std::vector<TreeNode *> allPossibleFBT(const size_t n) {
std::vector<TreeNode *> full_binary_trees;

if (n == 1) {
// full_binary_trees.push_back(new TreeNode(0));
full_binary_trees.emplace_back(new TreeNode(0));

} else if (n & 1) {
for (size_t index = 2; index <= n; index += 2) {
const auto left = allPossibleFBT(index - 1);
const auto right = allPossibleFBT(n - index);

for (size_t left_index = 0; left_index < left.size(); left_index++) {
for (size_t right_index = 0; right_index < right.size(); right_index++) {
full_binary_trees.emplace_back(new TreeNode(0));

if (right_index == right.size() - 1) {
full_binary_trees.back()->left = left(left_index);
} else {
full_binary_trees.back()->left = clone_tree(left(left_index));
}

if (left_index == left.size() - 1) {
full_binary_trees.back()->right = right(right_index);
} else {
full_binary_trees.back()->right = clone_tree(right(right_index));
}
}
}
}

}

return full_binary_trees;
}
};
``````

## binary tree – Is this model of converting integers to Gray code correct?

The model shown in the figure converts all numbers that have k digits in the binary system to Gray code without any calculation, but I have no proof that guarantees this claim.

Here is some information on how to use it.

Conversion model of all integers that have k digits in the binary system in Gray code.

Rules

1. You will need k columns of numbers. The numbers to be encoded are arranged in the last column.

2. The conversion is done gradually by transferring groups of numbers to the adjacent columns in the way the arrows show. There are two types of paired arrows, parallel (=) and intersecting (×). Symbolically, the (=) and (×) are considered inverse of each other.

3. Each column with arrows is formed by an exact copy of the previous column and by a copy of the previous column that has inverted pairs of arrows, which is placed below the exact copy.

Observation

If we set “=” = 0 and “×” = 1, then the successive columns containing arrows form the Thue Morse sequence which essentially forms the rules for converting integers to Gray code.

## differentiability – How to write a custom function to judge whether a binary function is differentiable at a certain point

We know that the necessary and sufficient conditions for a function of two variables to be differentiable at a certain point are complex.

Suppose the function $$z = f (x_ 1, x_ 2, …, x_n)$$ is defined in the neighborhood $$U$$ of the point $$P_ 0 (x_ {10}, x_ {20}, …, x_{n0})$$ , then the sufficient and necessary conditions for the function $$z = f (x_ 1, x_ 2, …, x_n)$$ to be differentiable at the point $$P_ 0 (x_ {10}, x_ {20}, …, x_{n0})$$ are: The n first-order partial derivatives of the function $$z = f (x_ 1, x_ 2, …, x_n)$$ at the point $$P_ 0 (x_ {10}, x_ {20}, …, x_{n0})$$ all exist, and $$f (x_ 1, x_ 2, …, x_n) – f (x_ {10}, x_ 2, …, x_n) – f (x_ 1, x_ {20}, …, x_n) – f (x_ 1, x_ 2, …, x_{n0}) + f (x_ {10}, x_ {20}, …, x_{n0}) = O (rho)$$ ;

Where $$(x_ 1, x_ 2, …, x_n) in U$$, $$rho = sqrt{(x_ 1 – x_ {10})^2 + (x_ 2 – x_ {20})^2 + … + (x_n – x_ {n0})^2}$$.

I already know that the following binary function $$f(x,y)$$ is differentiable at point {0,0}, but its two first-order partial derivatives are not continuous at {0,0}:
$$f(x, y)=begin{cases}(x^2 + y^2) sin(frac{1}{(x^2 + y^2)}), &(x, y) neq (0, 0) cr 0 , &(x, y)=(0, 0)end{cases}$$

I want to write a custom function to judge whether any binary function is differentiable at a certain point. How should I write this function?

For example, through this custom function, we can judge that the following binary function is not differentiable at {0,0}:

$$f(x, y)=begin{cases}frac{x^2y}{x^4 + y^2}, &(x, y) neq (0, 0) cr 0, &(x, y)=(0, 0)end{cases}$$

## binary trees – Efficiently storing and modifying a reorderable data structure in a database

I’m trying to create a list curation web app. One thing that’s important to me is being able to drag-and-drop reorder items in the list easily. At first I thought I could just store the order of each item, but with the reordering requirements, that would mean renumbering everything with a higher order (down the list) than the place where you removed or where you inserted the moved item. So I started looking at data structures that were friendly to reordering, or to both deletion and insertion. I’m looking at binary trees, probably red-black trees or something like that. I feel like I could with great effort probably implement the algorithms for manipulating those.

So here’s my actual question. All the tree tutorials assume you’re creating these trees in memory, usually through instantiating a simple Node class or whatever. But I’m going to be using a database to persist these structures, right? So one issue is how do I represent this data, which is kind of a broad question, sure. I would like to not have to read the whole tree from the database to update the order of one item in the list. But then again if I have to modify a lot of nodes that are stored as separate documents, that’s going to be expensive too, even if I have an index on the relevant fields, right? Like, every time I need to manipulate a node I need to actually find it in the database first, I think.

Also, I obviously need the content and order of each node on the front end in order to display the list, but do I need the client to know the whole tree structure in order to be able to send updates to the server, or can I just send the item id and its new position in the list or something?

I’m sorry if this veers too practical but I thought someone might want to take a crack at it.

In Binary ,when adding 1 + 1  it = ’10’

In decimal ,when adding 1 + 1 = 2  (The usual addition )

So in binary

100 + 11 = 111

but

101 + 11 = 1000

In the units column we have 1 + 1 = 10

So ‘o’ in the units column , carry ‘1’ in to the ‘tens’ column.

In the ‘tens’ column we have 1 + 1(carried forward) = 10

So ‘0’ in the ‘tens’ column , carry ‘1’ in to the ‘hundreds’ column.

In the ‘hundreds’ column we have ‘1 + 1(carried forward) = 10

So ‘0’ in the hundreds column , carry ‘1’ in to the ‘thousands’ column.

Since there are no other numbers in the ‘thousands’column we write ‘1’ .

NB The binary system is  used in computers because electrical charge, on microchip boards’,  is either ‘on’ or ‘off’ , or the electrical charge is either ‘+’ or ‘-‘

## c# – Algorithm to determine if binary tree is a Binary Search Tree (BST)

Continuing with algorithms I’ve implemented a binary search tree validator. I don’t like the two boolean variables within `NodeFollowsBSTContract` as it feels too complicated. I feel like it should be cleaned up but don’t see how, yet.

Also, before each recursive step down, to check child nodes, a new list is created. Is there’s a better way to implement this check that doesn’t repeatedly create new lists?

``````public class BinaryTreeNode
{
public BinaryTreeNode Left { get; set; }
public BinaryTreeNode Right { get; set; }

public int? Value { get; }

public BinaryTreeNode(int value)
{
Value = value;
}
}

public class ValidateBST
{
BinaryTreeNode _root;
public ValidateBST(BinaryTreeNode root)
{
_root = root;
}

public bool IsBinarySearchTree()
{
if ((_root.Left?.Value ?? 0) <= (_root.Value)
|| (_root.Right?.Value ?? 0) > (_root.Value))
{
var listIncludingRootValue = new List<int>()
{
_root.Value.Value
};

var leftLegValid = NodeFollowsBSTContract(_root.Left, new List<int>(), new List<int>(listIncludingRootValue));

var rightLegvalid = NodeFollowsBSTContract(_root.Right, new List<int>(listIncludingRootValue), new List<int>());

return leftLegValid && rightLegvalid;
}
else
{
return false;
}
}

private bool NodeFollowsBSTContract(BinaryTreeNode node, List<int> parentSmallerValues, List<int> parentLargerValues)
{
if (node == null)
{
return true;
}

bool isLessThanAllParentLargerValues = !parentLargerValues.Any()
|| parentLargerValues.Where(value => node.Value.Value <= value).Count() == parentLargerValues.Count;

bool isGreaterThanAllParentSmallerValues = !parentSmallerValues.Any()
|| parentSmallerValues.Where(value => node.Value.Value > value).Count() == parentSmallerValues.Count;

if (!isLessThanAllParentLargerValues || !isGreaterThanAllParentSmallerValues)
{
return false;
}

if (node.Left != null)
{
var updatedLargerValues = GenerateUpdatedLists(node.Value.Value, parentLargerValues);
var updatedSmallervalues = new List<int>(parentSmallerValues);

if (!NodeFollowsBSTContract(node.Left, updatedSmallervalues, updatedLargerValues))
{
return false;
}
}

if (node.Right != null)
{
var updatedvalues = GenerateUpdatedLists(node.Value.Value, parentSmallerValues);

if (!NodeFollowsBSTContract(node.Right, updatedvalues, parentLargerValues))
{
return false;
}
}

return true;
}

private List<int> GenerateUpdatedLists(int addValue, List<int> values)
{
var updatedValues = new List<int>(values)
{
};

return updatedValues;
}
}
``````

## binary – Does a megabyte represent (2^8)^1000000 bits in base2? Isn’t that more than enough combinations to represent everything?

Every introductory CompSci resource I can find goes through how 8 bits are in a byte, etc. So a byte can store some 2^8 values in binary. Then when asking about four bytes, we can assume this is (2^8)^4=2^32.

But I can’t find anywhere if this pattern holds up until the total amount of hard drive or memory storage. For instance, if even a single megabyte can really hold (2^8)^1000000 bits, isn’t this a number so large that it could store all data in existence everywhere in the universe many times over? The number of possible combinations from a number that large would surely never be reached. Yet in reality, we all know a megabyte isn’t much.

I can’t help but feel somewhere that the exponentiation must stop, and we instead multiply bytes together. Or is it really the case the numbers can get this big? Such as a gigabyte representing ((2^8)^1000)^3 bits?

If I can represent a number, let’s say, 1 million in 32 bits, and I wanted to store 10^50 numbers this large, wouldn’t the required bits be 2^32*10^50? First of all, I’d never need to store 10^50 of any unit of data on my hard drive, that’s astronomically massive, and secondly, 2^32*10^50 is quite a small number, far below (2^8)^1000000. So what’s really happening here that we need so much storage, and a megabyte isn’t much?

## c# – Xamarin binding Image as binary array within a ListView. Issue while removing entries from the observable collection

I have a xamarin android app which provides the option to make images. Those images will be stored into a database. The existing images will be displayed in a list view (as a preview). You need to be able to delete those images. Everything works fine except the image “removal”.
I am binding the images via ObservableCollection. Each object has a binary array property named “ImageDocumentData”. This property will be used as binding for the “Image.Source”. I am using a converter for the binding in order to convert the binary array into a ImageSource (via MemoryStream).
It does display everything correctly. However if I have more than one image in the preview listview and I start remove images from the ObservableCollection I am getting the runtime error:

System.ObjectDisposedException: ‘Cannot access a closed Stream.’

While rearranging the listview ui during runtime he is not getting into the converter functions again.
I am suspecting the following:
Each time after adding a new image to the ObservableCollection, the image control is disposing the ImageSource stream. After I remove an entry from the ObservableCollection, he is taking the internal cached ImageSource Object and is trying to read from the same stream again which he already disposed. He needs to get the Image Data again because after I delete an entry from the collection he needs to rearranging (redraw) the listview.
I really don’t know how to solve that issue. I need to use a stream within the image source because I only have a binary array (no file, no uri possible).
This is only my assumption. However I can’t see any other reasonable explanation for this runtime error. I’ve tried a few other options but so far none have worked for me, so I was hoping someone here can give me a hint into the correct direction.

This is my DTO:

``````    (DataContract)
public class RequestItemImageDocument : INotifyPropertyChanged
{

#region Fields
private Guid _requestItemImageDocId;
private Guid _orderItemId;
private byte() _imagedocData;
private string _documentDescription;
private DateTime? _storageDate;
private byte _isSynced;
#endregion

#region Properties
(DataMember)
public Guid RequestItemImageDocumentId
{
get
{
return _requestItemImageDocId;
}
set
{
_requestItemImageDocId = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("RequestItemImageDocumentId"));
}
}
(DataMember)
public Guid OrderItemId
{
get
{
return _orderItemId;
}
set
{
_orderItemId = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("OrderItemId"));
}
}

(DataMember)
public byte() ImageDocumentData
{
get
{
return _imagedocData;
}
set
{
_imagedocData = value;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("ImageDocumentData"));

}
}
}
(DataMember)
public string DocumentDescription
{
get
{
return _documentDescription;
}
set
{
_documentDescription = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("DocumentDescription"));
}
}
(DataMember)
public DateTime? StorageDate
{
get
{
return _storageDate;
}
set
{
_storageDate = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("StorageDate"));
}
}
(DataMember)
public byte IsSynced
{
get
{
return _isSynced;
}
set
{
_isSynced = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("IsSynced"));
}
}
#endregion
#region Constr
public RequestItemImageDocument()
{

}
#endregion
public event PropertyChangedEventHandler PropertyChanged;
}
``````

This is my view:

``````<?xml version="1.0" encoding="utf-8" ?>
<ui:PasAMBasePage
x:Class="AssetManagement.Mobile.Core.UI.OrderItemImageDocumentationPage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:AssetManagement.Mobile.Core.Controls"
xmlns:controls1="clr-namespace:UI.XF.Controls;assembly=UI"
xmlns:AppList="clr-namespace:Client.ApplicationDataModel.UI.Controls.AppList;assembly=Client.ApplicationDataModel.UI"
xmlns:res="clr-namespace:AssetManagement.Mobile.Core.Resources"
xmlns:ui="clr-namespace:AssetManagement.Mobile.Core.UI"
xmlns:valueconverter="clr-namespace:AssetManagement.Mobile.Core.Classes.ValueConverter"
xmlns:viewmodel="clr-namespace:AssetManagement.Mobile.Core.ViewModels"
Title="Bild Dokumentation"
x:TypeArguments="viewmodel:OrderItemImageDocuViewModel"><!--{res:Translate OrderItemImageDocumentary}-->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackLayout Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3">
<ListView ItemsSource="{Binding OrderItemImages}"
HasUnevenRows="true"
ItemSelected="OnListViewItemSelected"
ItemTapped="OnListViewItemTapped" x:Name="ImagePreviewListView">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid.Resources>
<valueconverter:ByteArrayToImageSourceConverter x:Key="SourceConverter" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Grid.RowSpan="2"
Source="{Binding ImageDocumentData, Converter={StaticResource SourceConverter}}"
Aspect="AspectFit"
HeightRequest="120"
WidthRequest="120" />
<Label Grid.Column="1"
Text="{Binding DocumentDescription}"
FontAttributes="Bold" />
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
<StackLayout Grid.Row="1" Grid.ColumnSpan="3" Grid.Column="0" Orientation="Horizontal" HorizontalOptions="End" VerticalOptions="End">
<controls:ImageButtonControl
Clicked="btnRemove_Clicked"
FontSize="30"
Glyph="trash-alt"
HeightRequest="60"
HorizontalOptions="End"/>
<controls:ImageButtonControl
FontSize="30"
Glyph="plus"
HeightRequest="60"
HorizontalOptions="End"/>
<controls:ImageButtonControl
Clicked="btnSave_Clicked"
FontSize="30"
Glyph="save"
HeightRequest="60"
HorizontalOptions="End"/>

</StackLayout>
</Grid>
</ui:PasAMBasePage>
``````

This is the code behind of the view:

``````    public partial class OrderItemImageDocumentationPage : PasAMBasePage<OrderItemImageDocuViewModel>
{
private IAppConfiguration _appConfig;

public OrderItemImageDocumentationPage()
{
InitializeComponent();
}

public OrderItemImageDocumentationPage(OrderItemImageDocuViewModel viewModel, IEventLogService eventLog, ILifetimeScope scope,
IUserInterfaceService uiService, IAppConfiguration appConfig)
: base(viewModel, eventLog, scope, uiService)
{
InitializeComponent();

_appConfig = appConfig;

ViewModel.PropertyChanged += ViewModel_PropertyChanged;
}

private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(OrderItemListViewModel.Order))
{
//orderItemAppList.EventContext = ViewModel;
}
}

private void OnListViewItemTapped(object sender, Xamarin.Forms.ItemTappedEventArgs e)
{

}

private void OnListViewItemSelected(object sender, Xamarin.Forms.SelectedItemChangedEventArgs e)
{

}

private async void btnAdd_Clicked(object sender, EventArgs e)
{
RequestItemImageDocument document = new RequestItemImageDocument();
document.RequestItemImageDocumentId = Guid.NewGuid();
await CrossMedia.Current.Initialize();
if (!CrossMedia.Current.IsCameraAvailable ||
!CrossMedia.Current.IsTakePhotoSupported)
{
await DisplayAlert("No Camera", "No camera available.", "OK");
return;
}
var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
Directory = "AssetDocumentary",
SaveToAlbum = true,
CompressionQuality = 75,
CustomPhotoSize = 50,
PhotoSize = PhotoSize.MaxWidthHeight,
MaxWidthHeight = 2000,
});
if (!string.IsNullOrEmpty(file.Path))
{
var result = await UserDialogs.Instance.PromptAsync("Fügen Sie eine optionale Textbeschreibung hinzu.", "Beschreibung");
document.DocumentDescription = result.Text;
byte() data = null;
using (var stream = file.GetStream())
{
var fInfo = new System.IO.FileInfo(file.Path);
data = new byte(fInfo.Length);
}
document.ImageDocumentData = data;

Android.Content.Context context = Android.App.Application.Context;
Android.Net.Uri filesUri = Android.Provider.MediaStore.Files.GetContentUri("external");
string where = Android.Provider.MediaStore.MediaColumns.Data + "=?";
//System.IO.File.Delete(file.Path);
context.ContentResolver.Delete(filesUri, where, new string() { file.Path });
}

}

private void btnSave_Clicked(object sender, EventArgs e)
{

}

private void btnRemove_Clicked(object sender, EventArgs e)
{
if (ImagePreviewListView.SelectedItem != null)
{
var selectedItem = ImagePreviewListView.SelectedItem as RequestItemImageDocument;
var test = ViewModel.OrderItemImages.FirstOrDefault(
c => c.RequestItemImageDocumentId.Equals(((RequestItemImageDocument)ImagePreviewListView.SelectedItem)
.RequestItemImageDocumentId));
ImagePreviewListView.SelectedItem = null;
ViewModel.OrderItemImages.Remove(test);
}
}
}
``````

This is my converter:

``````    public class ByteArrayToImageSourceConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
ImageSource xValue = null ;
try
{
if (value != null)
{
MemoryStream mem = new MemoryStream((byte())value);
xValue = ImageSource.FromStream(new Func<Stream>(() => { return mem; }));
}

}catch(Exception ex)
{

}
return xValue;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
``````

This is the view model:

``````    public class OrderItemImageDocuViewModel : ApplicationDataBaseViewModel, INavigationEventHandler
{
#region Klassenvariablen

private readonly int _pagingSize = 20;
private IAppConfiguration _appConfig;
private IBarcodeParserService _barcodeParser;
private IEventLogService _eventLog;
private IUserDataService _userData;
private ObservableCollection<RequestItemImageDocument> _orderItemImages = new ObservableCollection<RequestItemImageDocument>();
private OrderItem _orderItemContext = null;
#endregion Klassenvariablen

#region Konstruktor

public OrderItemImageDocuViewModel(ILifetimeScope scope, IDataRepositoryService dataRepository, IBarcodeParserService barcodeParserService, IEventLogService eventLog, IUserDataService userData, ITranslationService translationService, IAppConfiguration appConfig)
: base(dataRepository)
{
_eventLog = eventLog.Initialize(typeof(OrderItemImageDocuViewModel));
_scope = scope;
_appConfig = appConfig;
_userData = userData;
_barcodeParser = barcodeParserService;
TranslationService = translationService;

}

#endregion Konstruktor

#region Properties

public Order Order { get; set; }

public IEventLogService EventLog => _eventLog;

public bool DatabasesMissing { get; set; }

public ITranslationService TranslationService { get; set; }

public IList<OrderItem> OrderItems { get; set; }

public IOrderTypeScanHandling ScanHandler { get; set; }

public ObservableCollection<RequestItemImageDocument> OrderItemImages
{
get
{

return _orderItemImages;
}
set
{
_orderItemImages = value;
base.OnPropertyChanged("OrderItemImages");
}
}
#endregion Properties

#region Functions

#endregion

{
if (!DatabasesMissing)
{

try
{
//await InitializeData();

}
catch (Exception ex)
{
//ex.TrackError();
}

}
}

}
``````

## c++ – Generate binary image using coordinate vectors

I have a matrix `M` of size `(n_rows, n_cols)` and a list of `x` and `y` pixel coordinates. I use these coordinates to draw a binary image. Here is my code:

``````std::vector<std::vector<double>> x;
std::vector<std::vector<double>> y;

// fill x and y

std::vector<std::vector<unsigned int>> M(n_rows, std::vector<unsigned int>(n_cols));

std::vector<std::vector<double>>::const_iterator iter_row_x = x.begin();
std::vector<std::vector<double>>::const_iterator iter_row_y = y.begin();

for (; iter_row_x != x.end(); ++iter_row_x, ++iter_row_y) {
std::vector<double>::const_iterator iter_col_x = iter_row_x(0).begin();
std::vector<double>::const_iterator iter_col_y = iter_row_y(0).begin();
for (; iter_col_x != iter_row_x(0).end(); ++iter_col_x, ++iter_col_y) {
unsigned int i = unsigned int(*iter_col_x);
unsigned int j = unsigned int(*iter_col_y);
M(i)(j) = 1;
}
}
``````

I would like to know if there is a more elegant way to achieve this? My code above looks a bit bulky and error-prone for such a simple task.