Extracting data from a cell in Matlab - matlab
Suppose I have C cell as I mentioned below:
C =
[31, 17] [57, 17] [83, 17] [109, 17] [135, 17]
[31, 33] [57, 33] [83, 33] [109, 33] [135, 33]
[31, 49] [57, 49] [83, 49] [109, 49] [135, 49]
[31, 65] [57, 65] [83, 65] [109, 65] [135, 65]
[31, 81] [57, 81] [83, 81] [109, 81] [135, 81]
[31, 97] [57, 97] [83, 97] [109, 97] [135, 97]
[31, 113] [57, 113] [83, 113] [109, 113] [135, 113]
[31, 129] [57, 129] [83, 129] [109, 129] [135, 129]
[31, 145] [57, 145] [83, 145] [109, 145] [135, 145]
[31, 161] [57, 161] [83, 161] [109, 161] [135, 161]
[31, 177] [57, 177] [83, 177] [109, 177] [135, 177]
Now I want to extracting all of its data in new matrix-es
like this:
C11 = ([31,17] [57,17]; [31,33] [57,33])
C12 = ([57,17] [83,17]; [57,33] [83,33])
C13 = ([83,17] [109,17]; [83,33] [109,33])
C14 = ([109,17] [135,17]; [109,33] [135,33])
C21 = ([31,33] [57,33]; [31,49] [57,49])
C22 = ([57,33] [83,33]; [57,49] [83,49])
C23 = ([83,33] [109,33]; [83,49] [109,49])
....... ........ ....... ...... ..
C104 = ([109,161] [135,161]; [109,177] [109,177])
How can do that in Matlab?
Just use array subscripting with round parentheses. For instance ,C12 would be computed like so:
>> C12(1:2, 2:3)
ans =
{ [ 57 17 ] [ 83 17 ] }
{ [ 57 33 ] [ 83 33 ] }
You can do a for loop to iterate over your cell array and extract the necessary cells one by one, and store each one in a different variable. However, all the data is already stored C, so why duplicate it? I suggest that you keep everything in a cell array and extract matrices only when you need them.
Related
Scipy for Heart Rate data processing, Scipy.signal find_peaks returning empty array
Had an array with HR data in the form of BPMs (beats per minute). Need to split the data into segments where the HR was increasing, decreasing, and stayed the same to find the up/down amplitude and the associated times as well as the times when the heart rate did not change. To do so, tried using find_peaks to find the peaks and troughs of the HR data. To find troughs, I did a transformation of the original HR by multiplying it by -1 to find its peaks which in turn is the real troughs of the original HR data. find_peaks while specifying plateau and height, gives outputs that contains the peak location as well as the plateau locations and the peak values, example from below: find_peaks(arr, height=0.5, prominence=0.1, plateau_size=0.5) (array([ 9, 18, 33, 64, 70, 80, 87]), {'plateau_sizes': array([5, 2, 2, 3, 1, 3, 2]), 'left_edges': array([ 7, 18, 33, 63, 70, 79, 87]), 'right_edges': array([11, 19, 34, 65, 70, 81, 88]), 'peak_heights': array([ 80., 87., 81., 107., 106., 105., 105.]), 'prominences': array([ 2., 11., 2., 18., 3., 8., 8.]), 'left_bases': array([ 3, 3, 29, 43, 68, 74, 74]), 'right_bases': array([13, 40, 40, 98, 98, 98, 98])}) however, upon specifying height for the negative version of the original Heart rate Data to find the troughs and the heights, it returned empty array. If I remove the height=0.5, it outputs valid values except the peak_heights. find_peaks(trougharr,plateau_size=0.5,height=0.5) (array([], dtype=int64), {'plateau_sizes': array([], dtype=int64), 'left_edges': array([], dtype=int64), 'right_edges': array([], dtype=int64), 'peak_heights': array([], dtype=float64)}) Is there something wrong calling height with negative numbered arrays? If there's a easier method or simpler method for splitting up the data into up and down and constant portions, that would be much appreciated. the original sample HR data is as such: HR array([ 77, 77, 77, 76, 77, 78, 79, 80, 80, 80, 80, 80, 79, 78, 78, 79, 83, 85, 87, 87, 86, 86, 86, 85, 83, 81, 80, 79, 79, 79, 80, 80, 80, 81, 81, 80, 79, 79, 79, 74, 69, 69, 69, 69, 70, 70, 70, 70, 70, 71, 72, 80, 82, 89, 92, 95, 97, 99, 100, 102, 103, 105, 106, 107, 107, 107, 105, 104, 103, 105, 106, 102, 100, 97, 97, 98, 101, 102, 104, 105, 105, 105, 104, 104, 104, 104, 104, 105, 105, 104, 104, 104, 104, 98, 96, 93, 92, 90, 89]) -1*HR. (the problematic one) array([ -77, -77, -77, -76, -77, -78, -79, -80, -80, -80, -80, -80, -79, -78, -78, -79, -83, -85, -87, -87, -86, -86, -86, -85, -83, -81, -80, -79, -79, -79, -80, -80, -80, -81, -81, -80, -79, -79, -79, -74, -69, -69, -69, -69, -70, -70, -70, -70, -70, -71, -72, -80, -82, -89, -92, -95, -97, -99, -100, -102, -103, -105, -106, -107, -107, -107, -105, -104, -103, -105, -106, -102, -100, -97, -97, -98, -101, -102, -104, -105, -105, -105, -104, -104, -104, -104, -104, -105, -105, -104, -104, -104, -104, -98, -96, -93, -92, -90, -89]) Tried to split Heart Rate data into sections where it was increasing/decreasing/staying constant to find the up_amplitude,up_time, down_amplitude, down_time, time_constant. Found find_peaks to do it but it may not be the simplest, if there's a simpler method, please point me to it. Tried to use peak_prominences, but it did not detect all prominences for some reason, the codes tried were: peaks, _ = find_peaks(x) prominences = peak_prominences(x, peaks)[0] contour_heights = x[peaks] - prominences plt.plot(x) plt.plot(peaks, x[peaks], "x") plt.vlines(x=peaks, ymin=contour_heights, ymax=x[peaks]) plt.show() The prominences missed several locations.
Maximize profit with disregard to number of pickup-delivery done OR tools
I am trying to maximize profit, whether I deliver all pickups-deliveries does not matter. I tried setting SetArcCostEvaluatorOfAllVehicles to use negative profit instead of cost callback; however, this does not work, an I get no solution often, my thought is that cost cannot be negative. Is this correct? Adding AddVariableMaximizedByFinalizer with profit callback does not seem to work, because it runs after the solutions are already found, and therefore it will not eliminate deliveries that are not profitable. Is this correct? My gut feeling is that I need set a metric (profit dimension?) that evaluates the performance of solver, and use AddDisjunction with punishment for missing pickup-delivery set to 0, to eliminate not profitable deliveries. Is something like this possible? If not, what is the recommended approach? Edit: Here is my code, it is a very small modification of: https://developers.google.com/optimization/routing/pickup_delivery """Simple Pickup Delivery Problem (PDP).""" from __future__ import print_function from ortools.constraint_solver import routing_enums_pb2 from ortools.constraint_solver import pywrapcp def create_data_model(): """Stores the data for the problem.""" data = {} data['distance_matrix'] = [ [ 0, 548, 776, 696, 582, 274, 502, 194, 308, 194, 536, 502, 388, 354, 468, 776, 662 ], [ 548, 0, 684, 308, 194, 502, 730, 354, 696, 742, 1084, 594, 480, 674, 1016, 868, 1210 ], [ 776, 684, 0, 992, 878, 502, 274, 810, 468, 742, 400, 1278, 1164, 1130, 788, 1552, 754 ], [ 696, 308, 992, 0, 114, 650, 878, 502, 844, 890, 1232, 514, 628, 822, 1164, 560, 1358 ], [ 582, 194, 878, 114, 0, 536, 764, 388, 730, 776, 1118, 400, 514, 708, 1050, 674, 1244 ], [ 274, 502, 502, 650, 536, 0, 228, 308, 194, 240, 582, 776, 662, 628, 514, 1050, 708 ], [ 502, 730, 274, 878, 764, 228, 0, 536, 194, 468, 354, 1004, 890, 856, 514, 1278, 480 ], [ 194, 354, 810, 502, 388, 308, 536, 0, 342, 388, 730, 468, 354, 320, 662, 742, 856 ], [ 308, 696, 468, 844, 730, 194, 194, 342, 0, 274, 388, 810, 696, 662, 320, 1084, 514 ], [ 194, 742, 742, 890, 776, 240, 468, 388, 274, 0, 342, 536, 422, 388, 274, 810, 468 ], [ 536, 1084, 400, 1232, 1118, 582, 354, 730, 388, 342, 0, 878, 764, 730, 388, 1152, 354 ], [ 502, 594, 1278, 514, 400, 776, 1004, 468, 810, 536, 878, 0, 114, 308, 650, 274, 844 ], [ 388, 480, 1164, 628, 514, 662, 890, 354, 696, 422, 764, 114, 0, 194, 536, 388, 730 ], [ 354, 674, 1130, 822, 708, 628, 856, 320, 662, 388, 730, 308, 194, 0, 342, 422, 536 ], [ 468, 1016, 788, 1164, 1050, 514, 514, 662, 320, 274, 388, 650, 536, 342, 0, 764, 194 ], [ 776, 868, 1552, 560, 674, 1050, 1278, 742, 1084, 810, 1152, 274, 388, 422, 764, 0, 798 ], [ 662, 1210, 754, 1358, 1244, 708, 480, 856, 514, 468, 354, 844, 730, 536, 194, 798, 0 ], ] data['pickups_deliveries'] = [ [1, 6], [2, 10], [4, 3], [5, 9], [7, 8], [15, 11], [13, 12], [16, 14], ] data['num_vehicles'] = 4 data['depot'] = 0 data['revenue'] = {6: 1000000, 10: 100, 3: 100, 9: 100, 8: 100, 11: 100, 12: 100, 14: 100 } return data def print_solution(data, manager, routing, solution): """Prints solution on console.""" total_distance = 0 for vehicle_id in range(data['num_vehicles']): index = routing.Start(vehicle_id) plan_output = 'Route for vehicle {}:\n'.format(vehicle_id) route_distance = 0 while not routing.IsEnd(index): plan_output += ' {} -> '.format(manager.IndexToNode(index)) previous_index = index index = solution.Value(routing.NextVar(index)) route_distance += routing.GetArcCostForVehicle( previous_index, index, vehicle_id) plan_output += '{}\n'.format(manager.IndexToNode(index)) plan_output += 'Distance of the route: {}m\n'.format(route_distance) print(plan_output) total_distance += route_distance print('Total Distance of all routes: {}m'.format(total_distance)) def main(): """Entry point of the program.""" # Instantiate the data problem. data = create_data_model() # Create the routing index manager. manager = pywrapcp.RoutingIndexManager(len(data['distance_matrix']), data['num_vehicles'], data['depot']) # Create Routing Model. routing = pywrapcp.RoutingModel(manager) # Define cost of each arc. def distance_callback(from_index, to_index): """Returns the manhattan distance between the two nodes.""" # Convert from routing variable Index to distance matrix NodeIndex. from_node = manager.IndexToNode(from_index) to_node = manager.IndexToNode(to_index) return data['distance_matrix'][from_node][to_node] transit_callback_index = routing.RegisterTransitCallback(distance_callback) routing.SetArcCostEvaluatorOfAllVehicles(transit_callback_index) # Add Distance constraint. dimension_name = 'Distance' routing.AddDimension( transit_callback_index, 0, # no slack 3000, # vehicle maximum travel distance True, # start cumul to zero dimension_name) distance_dimension = routing.GetDimensionOrDie(dimension_name) distance_dimension.SetGlobalSpanCostCoefficient(100) # Define Transportation Requests. for request in data['pickups_deliveries']: pickup_index = manager.NodeToIndex(request[0]) delivery_index = manager.NodeToIndex(request[1]) routing.AddPickupAndDelivery(pickup_index, delivery_index) routing.solver().Add( routing.VehicleVar(pickup_index) == routing.VehicleVar( delivery_index)) routing.solver().Add( distance_dimension.CumulVar(pickup_index) <= distance_dimension.CumulVar(delivery_index)) for node, revenue in data["revenue"].items(): routing.AddDisjunction( [manager.NodeToIndex(node)], revenue ) # Setting first solution heuristic. search_parameters = pywrapcp.DefaultRoutingSearchParameters() search_parameters.first_solution_strategy = ( routing_enums_pb2.FirstSolutionStrategy.PARALLEL_CHEAPEST_INSERTION) # Solve the problem. solution = routing.SolveWithParameters(search_parameters) # Print solution on console. if solution: print_solution(data, manager, routing, solution) if __name__ == '__main__': main() I addeded: data['revenue'] = {6: 1000000, 10: 100, 3: 100, 9: 100, 8: 100, 11: 100, 12: 100, 14: 100 } and for node, revenue in data["revenue"].items(): routing.AddDisjunction( [manager.NodeToIndex(node)], revenue) When I run this code all pickup-deliveries get delivered (even if I hard code revenue to 0). I am looking for a solution where only [1, 6] is delivered, because it is the only one that gives profit. I think I see where my issue is coming from. When pickup deliveries constraints are setup, the cost is minimized given these constraints. And since all of these constraints can be satisfied all pickup-deliveries get delivered. Is there a way to make pickup-deliveries constraints soft, and focus on minimizing the cost (plus the punishment)?
If you add a penalty of 0 to deliveries, the solver will happily drop all of them. Also, non profitable is in the context of the route. Therefore, you need to tweak the penalties to get what you want. Response to edit: To make a PDP soft, you need to add 2 disjunctions, one for the pickup, and one for the delivery.
Here is the code that I ended up using: """Simple Pickup Delivery Problem (PDP).""" from __future__ import print_function from ortools.constraint_solver import routing_enums_pb2 from ortools.constraint_solver import pywrapcp def create_data_model(): """Stores the data for the problem.""" data = {} data['distance_matrix'] = [ [ 0, 548, 776, 696, 582, 274, 502, 194, 308, 194, 536, 502, 388, 354, 468, 776, 662 ], [ 548, 0, 684, 308, 194, 502, 730, 354, 696, 742, 1084, 594, 480, 674, 1016, 868, 1210 ], [ 776, 684, 0, 992, 878, 502, 274, 810, 468, 742, 400, 1278, 1164, 1130, 788, 1552, 754 ], [ 696, 308, 992, 0, 114, 650, 878, 502, 844, 890, 1232, 514, 628, 822, 1164, 560, 1358 ], [ 582, 194, 878, 114, 0, 536, 764, 388, 730, 776, 1118, 400, 514, 708, 1050, 674, 1244 ], [ 274, 502, 502, 650, 536, 0, 228, 308, 194, 240, 582, 776, 662, 628, 514, 1050, 708 ], [ 502, 730, 274, 878, 764, 228, 0, 536, 194, 468, 354, 1004, 890, 856, 514, 1278, 480 ], [ 194, 354, 810, 502, 388, 308, 536, 0, 342, 388, 730, 468, 354, 320, 662, 742, 856 ], [ 308, 696, 468, 844, 730, 194, 194, 342, 0, 274, 388, 810, 696, 662, 320, 1084, 514 ], [ 194, 742, 742, 890, 776, 240, 468, 388, 274, 0, 342, 536, 422, 388, 274, 810, 468 ], [ 536, 1084, 400, 1232, 1118, 582, 354, 730, 388, 342, 0, 878, 764, 730, 388, 1152, 354 ], [ 502, 594, 1278, 514, 400, 776, 1004, 468, 810, 536, 878, 0, 114, 308, 650, 274, 844 ], [ 388, 480, 1164, 628, 514, 662, 890, 354, 696, 422, 764, 114, 0, 194, 536, 388, 730 ], [ 354, 674, 1130, 822, 708, 628, 856, 320, 662, 388, 730, 308, 194, 0, 342, 422, 536 ], [ 468, 1016, 788, 1164, 1050, 514, 514, 662, 320, 274, 388, 650, 536, 342, 0, 764, 194 ], [ 776, 868, 1552, 560, 674, 1050, 1278, 742, 1084, 810, 1152, 274, 388, 422, 764, 0, 798 ], [ 662, 1210, 754, 1358, 1244, 708, 480, 856, 514, 468, 354, 844, 730, 536, 194, 798, 0 ], ] data['pickups_deliveries'] = [ [1, 6], [2, 10], [4, 3], [5, 9], [7, 8], [15, 11], [13, 12], [16, 14], ] data['num_vehicles'] = 4 data['depot'] = 0 data['revenue'] = {(1, 6): 1000000, (2, 10): 100, (4, 3): 100, (5, 9): 10000, (7, 8): 100, (15, 11): 100, (13, 12): 100, (16, 14): 100 } return data def print_solution(data, manager, routing, solution): """Prints solution on console.""" total_distance = 0 for vehicle_id in range(data['num_vehicles']): index = routing.Start(vehicle_id) plan_output = 'Route for vehicle {}:\n'.format(vehicle_id) route_distance = 0 while not routing.IsEnd(index): plan_output += ' {} -> '.format(manager.IndexToNode(index)) previous_index = index index = solution.Value(routing.NextVar(index)) route_distance += routing.GetArcCostForVehicle( previous_index, index, vehicle_id) plan_output += '{}\n'.format(manager.IndexToNode(index)) plan_output += 'Distance of the route: {}m\n'.format(route_distance) print(plan_output) total_distance += route_distance print('Total Distance of all routes: {}m'.format(total_distance)) def main(): """Entry point of the program.""" # Instantiate the data problem. data = create_data_model() # Create the routing index manager. manager = pywrapcp.RoutingIndexManager(len(data['distance_matrix']), data['num_vehicles'], data['depot']) # Create Routing Model. routing = pywrapcp.RoutingModel(manager) # Define cost of each arc. def distance_callback(from_index, to_index): """Returns the manhattan distance between the two nodes.""" # Convert from routing variable Index to distance matrix NodeIndex. from_node = manager.IndexToNode(from_index) to_node = manager.IndexToNode(to_index) return data['distance_matrix'][from_node][to_node] transit_callback_index = routing.RegisterTransitCallback(distance_callback) routing.SetArcCostEvaluatorOfAllVehicles(transit_callback_index) # Add Distance constraint. dimension_name = 'Distance' routing.AddDimension( transit_callback_index, 0, # no slack 3000, # vehicle maximum travel distance True, # start cumul to zero dimension_name) distance_dimension = routing.GetDimensionOrDie(dimension_name) distance_dimension.SetGlobalSpanCostCoefficient(100) # Define Transportation Requests. for request in data['pickups_deliveries']: pickup_index = manager.NodeToIndex(request[0]) delivery_index = manager.NodeToIndex(request[1]) routing.AddPickupAndDelivery(pickup_index, delivery_index) routing.solver().Add( routing.VehicleVar(pickup_index) == routing.VehicleVar( delivery_index)) routing.solver().Add( distance_dimension.CumulVar(pickup_index) <= distance_dimension.CumulVar(delivery_index)) for node, revenue in data["revenue"].items(): start, end = node routing.AddDisjunction( [manager.NodeToIndex(end)], revenue ) routing.AddDisjunction( [manager.NodeToIndex(start)], 0 ) # Setting first solution heuristic. search_parameters = pywrapcp.DefaultRoutingSearchParameters() search_parameters.first_solution_strategy = ( routing_enums_pb2.FirstSolutionStrategy.PARALLEL_CHEAPEST_INSERTION) # Solve the problem. solution = routing.SolveWithParameters(search_parameters) # Print solution on console. if solution: print_solution(data, manager, routing, solution) if __name__ == '__main__': main()
Mapbox - Get region from autocomplete result
How can I get region from the selected result from autocomplete? From the result I am getting, there is 3rd object named region but actually it is department not region. Here is the example address: 54b route de brie, 91800 Brunoy, France Mapbox is giving me: Essonne // Its department not region But actually its: Ile-de-France How do I get the correct region? Here is my working demo: https://jsfiddle.net/rv085oL1/
That information isn't included. But if you just need your site to work in France, it would be straightforward to include a lookup table mapping from département to région, using the last two characters of the short_code. Here's one: https://gist.github.com/SiamKreative/f1074ed95507e69d08a0 "regions": { "alsace": [67, 68], "aquitaine": [40, 47, 33, 24, 64], "auvergne": [43, 3, 15, 63], "basse-normandie": [14, 61, 50], "bourgogne": [21, 58, 71, 89], "bretagne": [29, 35, 22, 56], "centre": [45, 37, 41, 28, 36, 18], "champagne-ardenne": [10, 8, 52, 51], "corse": ["2b", "2a"], "franche-compte": [39, 25, 70, 90], "haute-normandie": [27, 76], "languedoc-roussillon": [48, 30, 34, 11, 66], "limousin": [19, 23, 87], "lorraine": [55, 54, 57, 88], "midi-pyrennees": [46, 32, 31, 12, 9, 65, 81, 82], "nord-pas-de-calais": [62, 59], "pays-de-la-loire": [49, 44, 72, 53, 85], "picardie": [2, 60, 80], "poitou-charentes": [17, 16, 86, 79], "provences-alpes-cote-dazur": [4, 5, 6, 13, 84, 83], "rhones-alpes": [38, 42, 26, 7, 1, 74, 73, 69], "ile-de-france": [77, 75, 78, 93, 92, 91, 95, 94] },
polyhedron not filled (openscad)
i have a polyhedron that seams to be well-formed with no overlap. i have no error or warning when i press f6, and when i press f12 to check if i have missordered faces , no pink face are displayed from outside ( all faces from inside the object are all pink which is consistent ) . i have to do a difference between this object and another one but my polyhedron is never solid. Did i missunderstood something ? thanks a lot for any advices. points = [[5.01, -10.505, -1.5], [6.5345, -10.5048, -1.5], [8.059, -10.5045, -1.5], [9.5835, -10.5042, -1.5], [11.108, -10.504, -1.5], [12.6325, -10.5038, -1.5], [14.157, -10.5035, -1.5], [15.6815, -10.5033, -1.5], [17.206, -10.503, -1.5], [18.7305, -10.5028, -1.5], [20.255, -10.5025, -1.5], [21.7795, -10.5023, -1.5], [23.304, -10.502, -1.5], [24.8285, -10.5018, -1.5], [26.353, -10.5015, -1.5], [27.8775, -10.5012, -1.5], [29.402, -10.501, -1.5], [30.9265, -10.5008, -1.5], [32.451, -10.5005, -1.5], [33.9755, -10.5002, -1.5], [35.5, -10.5, -1.5], [5, -10.5, -1.5], [5.31731, -10.5, -0.733875], [5.9485, -10.5, -0.081], [6.86244, -10.5, 0.465375], [8.028, -10.5, 0.912], [9.41406, -10.5, 1.26562], [10.9895, -10.5, 1.533], [12.7232, -10.5, 1.72087], [14.584, -10.5, 1.836], [16.5408, -10.5, 1.88512], [18.5625, -10.5, 1.875], [20.6179, -10.5, 1.81238], [22.676, -10.5, 1.704], [24.7056, -10.5, 1.55662], [26.6755, -10.5, 1.377], [28.5547, -10.5, 1.17187], [30.312, -10.5, 0.948], [31.9163, -10.5, 0.712125], [33.3365, -10.5, 0.471], [34.5414, -10.5, 0.231375], [35.5, -10.5, 0], [2.5, -8.5, -1.5], [3.54437, -8.78162, 0.442813], [4.72, -9.028, 2.0875], [6.01562, -9.24137, 3.45844], [7.42, -9.424, 4.58], [8.92188, -9.57812, 5.47656], [10.51, -9.706, 6.1725], [12.1731, -9.80988, 6.69219], [13.9, -9.892, 7.06], [15.6794, -9.95463, 7.30031], [17.5, -10, 7.4375], [19.3506, -10.0304, 7.49594], [21.22, -10.048, 7.5], [23.0969, -10.0551, 7.47406], [24.97, -10.054, 7.4425], [26.8281, -10.0469, 7.42969], [28.66, -10.036, 7.46], [30.4544, -10.0236, 7.55781], [32.2, -10.012, 7.7475], [33.8856, -10.0034, 8.05344], [35.5, -10, 8.5], [-1, -5, -1.5], [0.543563, -5.30675, 0.389375], [2.1685, -5.624, 2.02], [3.86619, -5.94725, 3.41063], [5.628, -6.272, 4.58], [7.44531, -6.59375, 5.54688], [9.3095, -6.908, 6.33], [11.2119, -7.21025, 6.94812], [13.144, -7.496, 7.42], [15.0971, -7.76075, 7.76438], [17.0625, -8, 8], [19.0317, -8.20925, 8.14562], [20.996, -8.384, 8.22], [22.9468, -8.51975, 8.24188], [24.8755, -8.612, 8.23], [26.7734, -8.65625, 8.20312], [28.632, -8.648, 8.18], [30.4426, -8.58275, 8.17938], [32.1965, -8.456, 8.22], [33.8852, -8.26325, 8.32063], [35.5, -8, 8.5], [-2, -3, -1.5], [-0.584562, -3.30662, 0.788375], [0.9535, -3.623, 2.722], [2.60181, -3.94387, 4.32863], [4.348, -4.264, 5.636], [6.17969, -4.57812, 6.67188], [8.0845, -4.881, 7.464], [10.0501, -5.16738, 8.04012], [12.064, -5.432, 8.428], [14.1139, -5.66962, 8.65537], [16.1875, -5.875, 8.75], [18.2723, -6.04288, 8.73963], [20.356, -6.168, 8.652], [22.4262, -6.24512, 8.51487], [24.4705, -6.269, 8.356], [26.4766, -6.23438, 8.20312], [28.432, -6.136, 8.084], [30.3244, -5.96863, 8.02638], [32.1415, -5.727, 8.058], [33.8708, -5.40587, 8.20663], [35.5, -5, 8.5], [-3, 0, -1.5], [-1.13556, 0, 1.20887], [0.8455, 0, 3.506], [2.92481, 0, 5.42212], [5.084, 0, 6.988], [7.30469, 0, 8.23438], [9.5685, 0, 9.192], [11.8571, 0, 9.89162], [14.152, 0, 10.364], [16.4349, 0, 10.6399], [18.6875, 0, 10.75], [20.8913, 0, 10.7251], [23.028, 0, 10.596], [25.0792, 0, 10.3934], [27.0265, 0, 10.148], [28.8516, 0, 9.89062], [30.536, 0, 9.652], [32.0614, 0, 9.46287], [33.4095, 0, 9.354], [34.5618, 0, 9.35613], [35.5, 0, 9.5], [-2, 3, -1.5], [-0.584562, 3.30662, 0.788375], [0.9535, 3.623, 2.722], [2.60181, 3.94387, 4.32863], [4.348, 4.264, 5.636], [6.17969, 4.57812, 6.67188], [8.0845, 4.881, 7.464], [10.0501, 5.16738, 8.04012], [12.064, 5.432, 8.428], [14.1139, 5.66962, 8.65537], [16.1875, 5.875, 8.75], [18.2723, 6.04288, 8.73963], [20.356, 6.168, 8.652], [22.4262, 6.24512, 8.51487], [24.4705, 6.269, 8.356], [26.4766, 6.23438, 8.20312], [28.432, 6.136, 8.084], [30.3244, 5.96863, 8.02638], [32.1415, 5.727, 8.058], [33.8708, 5.40587, 8.20663], [35.5, 5, 8.5], [-1, 5, -1.5], [0.543563, 5.30675, 0.389375], [2.1685, 5.624, 2.02], [3.86619, 5.94725, 3.41063], [5.628, 6.272, 4.58], [7.44531, 6.59375, 5.54688], [9.3095, 6.908, 6.33], [11.2119, 7.21025, 6.94812], [13.144, 7.496, 7.42], [15.0971, 7.76075, 7.76438], [17.0625, 8, 8], [19.0317, 8.20925, 8.14562], [20.996, 8.384, 8.22], [22.9468, 8.51975, 8.24188], [24.8755, 8.612, 8.23], [26.7734, 8.65625, 8.20312], [28.632, 8.648, 8.18], [30.4426, 8.58275, 8.17938], [32.1965, 8.456, 8.22], [33.8852, 8.26325, 8.32063], [35.5, 8, 8.5], [2.5, 8.5, -1.5], [3.54437, 8.78162, 0.442813], [4.72, 9.028, 2.0875], [6.01562, 9.24137, 3.45844], [7.42, 9.424, 4.58], [8.92188, 9.57812, 5.47656], [10.51, 9.706, 6.1725], [12.1731, 9.80988, 6.69219], [13.9, 9.892, 7.06], [15.6794, 9.95463, 7.30031], [17.5, 10, 7.4375], [19.3506, 10.0304, 7.49594], [21.22, 10.048, 7.5], [23.0969, 10.0551, 7.47406], [24.97, 10.054, 7.4425], [26.8281, 10.0469, 7.42969], [28.66, 10.036, 7.46], [30.4544, 10.0236, 7.55781], [32.2, 10.012, 7.7475], [33.8856, 10.0034, 8.05344], [35.5, 10, 8.5], [5, 10.5, -1.5], [5.31731, 10.5, -0.733875], [5.9485, 10.5, -0.081], [6.86244, 10.5, 0.465375], [8.028, 10.5, 0.912], [9.41406, 10.5, 1.26562], [10.9895, 10.5, 1.533], [12.7232, 10.5, 1.72087], [14.584, 10.5, 1.836], [16.5408, 10.5, 1.88512], [18.5625, 10.5, 1.875], [20.6179, 10.5, 1.81238], [22.676, 10.5, 1.704], [24.7056, 10.5, 1.55662], [26.6755, 10.5, 1.377], [28.5547, 10.5, 1.17187], [30.312, 10.5, 0.948], [31.9163, 10.5, 0.712125], [33.3365, 10.5, 0.471], [34.5414, 10.5, 0.231375], [35.5, 10.5, 0], [5.01, 10.505, -1.5], [6.5345, 10.5048, -1.5], [8.059, 10.5045, -1.5], [9.5835, 10.5042, -1.5], [11.108, 10.504, -1.5], [12.6325, 10.5038, -1.5], [14.157, 10.5035, -1.5], [15.6815, 10.5033, -1.5], [17.206, 10.503, -1.5], [18.7305, 10.5028, -1.5], [20.255, 10.5025, -1.5], [21.7795, 10.5023, -1.5], [23.304, 10.502, -1.5], [24.8285, 10.5018, -1.5], [26.353, 10.5015, -1.5], [27.8775, 10.5012, -1.5], [29.402, 10.501, -1.5], [30.9265, 10.5008, -1.5], [32.451, 10.5005, -1.5], [33.9755, 10.5002, -1.5], [35.5, 10.5, -1.5]]; faces = [[0, 21, 1], [21, 22, 1], [1, 22, 2], [22, 23, 2], [2, 23, 3], [23, 24, 3], [3, 24, 4], [24, 25, 4], [4, 25, 5], [25, 26, 5], [5, 26, 6], [26, 27, 6], [6, 27, 7], [27, 28, 7], [7, 28, 8], [28, 29, 8], [8, 29, 9], [29, 30, 9], [9, 30, 10], [30, 31, 10], [10, 31, 11], [31, 32, 11], [11, 32, 12], [32, 33, 12], [12, 33, 13], [33, 34, 13], [13, 34, 14], [34, 35, 14], [14, 35, 15], [35, 36, 15], [15, 36, 16], [36, 37, 16], [16, 37, 17], [37, 38, 17], [17, 38, 18], [38, 39, 18], [18, 39, 19], [39, 40, 19], [19, 40, 20], [40, 41, 20], [21, 42, 22], [42, 43, 22], [22, 43, 23], [43, 44, 23], [23, 44, 24], [44, 45, 24], [24, 45, 25], [45, 46, 25], [25, 46, 26], [46, 47, 26], [26, 47, 27], [47, 48, 27], [27, 48, 28], [48, 49, 28], [28, 49, 29], [49, 50, 29], [29, 50, 30], [50, 51, 30], [30, 51, 31], [51, 52, 31], [31, 52, 32], [52, 53, 32], [32, 53, 33], [53, 54, 33], [33, 54, 34], [54, 55, 34], [34, 55, 35], [55, 56, 35], [35, 56, 36], [56, 57, 36], [36, 57, 37], [57, 58, 37], [37, 58, 38], [58, 59, 38], [38, 59, 39], [59, 60, 39], [39, 60, 40], [60, 61, 40], [40, 61, 41], [61, 62, 41], [42, 63, 43], [63, 64, 43], [43, 64, 44], [64, 65, 44], [44, 65, 45], [65, 66, 45], [45, 66, 46], [66, 67, 46], [46, 67, 47], [67, 68, 47], [47, 68, 48], [68, 69, 48], [48, 69, 49], [69, 70, 49], [49, 70, 50], [70, 71, 50], [50, 71, 51], [71, 72, 51], [51, 72, 52], [72, 73, 52], [52, 73, 53], [73, 74, 53], [53, 74, 54], [74, 75, 54], [54, 75, 55], [75, 76, 55], [55, 76, 56], [76, 77, 56], [56, 77, 57], [77, 78, 57], [57, 78, 58], [78, 79, 58], [58, 79, 59], [79, 80, 59], [59, 80, 60], [80, 81, 60], [60, 81, 61], [81, 82, 61], [61, 82, 62], [82, 83, 62], [63, 84, 64], [84, 85, 64], [64, 85, 65], [85, 86, 65], [65, 86, 66], [86, 87, 66], [66, 87, 67], [87, 88, 67], [67, 88, 68], [88, 89, 68], [68, 89, 69], [89, 90, 69], [69, 90, 70], [90, 91, 70], [70, 91, 71], [91, 92, 71], [71, 92, 72], [92, 93, 72], [72, 93, 73], [93, 94, 73], [73, 94, 74], [94, 95, 74], [74, 95, 75], [95, 96, 75], [75, 96, 76], [96, 97, 76], [76, 97, 77], [97, 98, 77], [77, 98, 78], [98, 99, 78], [78, 99, 79], [99, 100, 79], [79, 100, 80], [100, 101, 80], [80, 101, 81], [101, 102, 81], [81, 102, 82], [102, 103, 82], [82, 103, 83], [103, 104, 83], [84, 105, 85], [105, 106, 85], [85, 106, 86], [106, 107, 86], [86, 107, 87], [107, 108, 87], [87, 108, 88], [108, 109, 88], [88, 109, 89], [109, 110, 89], [89, 110, 90], [110, 111, 90], [90, 111, 91], [111, 112, 91], [91, 112, 92], [112, 113, 92], [92, 113, 93], [113, 114, 93], [93, 114, 94], [114, 115, 94], [94, 115, 95], [115, 116, 95], [95, 116, 96], [116, 117, 96], [96, 117, 97], [117, 118, 97], [97, 118, 98], [118, 119, 98], [98, 119, 99], [119, 120, 99], [99, 120, 100], [120, 121, 100], [100, 121, 101], [121, 122, 101], [101, 122, 102], [122, 123, 102], [102, 123, 103], [123, 124, 103], [103, 124, 104], [124, 125, 104], [105, 126, 106], [126, 127, 106], [106, 127, 107], [127, 128, 107], [107, 128, 108], [128, 129, 108], [108, 129, 109], [129, 130, 109], [109, 130, 110], [130, 131, 110], [110, 131, 111], [131, 132, 111], [111, 132, 112], [132, 133, 112], [112, 133, 113], [133, 134, 113], [113, 134, 114], [134, 135, 114], [114, 135, 115], [135, 136, 115], [115, 136, 116], [136, 137, 116], [116, 137, 117], [137, 138, 117], [117, 138, 118], [138, 139, 118], [118, 139, 119], [139, 140, 119], [119, 140, 120], [140, 141, 120], [120, 141, 121], [141, 142, 121], [121, 142, 122], [142, 143, 122], [122, 143, 123], [143, 144, 123], [123, 144, 124], [144, 145, 124], [124, 145, 125], [145, 146, 125], [126, 147, 127], [147, 148, 127], [127, 148, 128], [148, 149, 128], [128, 149, 129], [149, 150, 129], [129, 150, 130], [150, 151, 130], [130, 151, 131], [151, 152, 131], [131, 152, 132], [152, 153, 132], [132, 153, 133], [153, 154, 133], [133, 154, 134], [154, 155, 134], [134, 155, 135], [155, 156, 135], [135, 156, 136], [156, 157, 136], [136, 157, 137], [157, 158, 137], [137, 158, 138], [158, 159, 138], [138, 159, 139], [159, 160, 139], [139, 160, 140], [160, 161, 140], [140, 161, 141], [161, 162, 141], [141, 162, 142], [162, 163, 142], [142, 163, 143], [163, 164, 143], [143, 164, 144], [164, 165, 144], [144, 165, 145], [165, 166, 145], [145, 166, 146], [166, 167, 146], [147, 168, 148], [168, 169, 148], [148, 169, 149], [169, 170, 149], [149, 170, 150], [170, 171, 150], [150, 171, 151], [171, 172, 151], [151, 172, 152], [172, 173, 152], [152, 173, 153], [173, 174, 153], [153, 174, 154], [174, 175, 154], [154, 175, 155], [175, 176, 155], [155, 176, 156], [176, 177, 156], [156, 177, 157], [177, 178, 157], [157, 178, 158], [178, 179, 158], [158, 179, 159], [179, 180, 159], [159, 180, 160], [180, 181, 160], [160, 181, 161], [181, 182, 161], [161, 182, 162], [182, 183, 162], [162, 183, 163], [183, 184, 163], [163, 184, 164], [184, 185, 164], [164, 185, 165], [185, 186, 165], [165, 186, 166], [186, 187, 166], [166, 187, 167], [187, 188, 167], [168, 189, 169], [189, 190, 169], [169, 190, 170], [190, 191, 170], [170, 191, 171], [191, 192, 171], [171, 192, 172], [192, 193, 172], [172, 193, 173], [193, 194, 173], [173, 194, 174], [194, 195, 174], [174, 195, 175], [195, 196, 175], [175, 196, 176], [196, 197, 176], [176, 197, 177], [197, 198, 177], [177, 198, 178], [198, 199, 178], [178, 199, 179], [199, 200, 179], [179, 200, 180], [200, 201, 180], [180, 201, 181], [201, 202, 181], [181, 202, 182], [202, 203, 182], [182, 203, 183], [203, 204, 183], [183, 204, 184], [204, 205, 184], [184, 205, 185], [205, 206, 185], [185, 206, 186], [206, 207, 186], [186, 207, 187], [207, 208, 187], [187, 208, 188], [208, 209, 188], [189, 210, 190], [210, 211, 190], [190, 211, 191], [211, 212, 191], [191, 212, 192], [212, 213, 192], [192, 213, 193], [213, 214, 193], [193, 214, 194], [214, 215, 194], [194, 215, 195], [215, 216, 195], [195, 216, 196], [216, 217, 196], [196, 217, 197], [217, 218, 197], [197, 218, 198], [218, 219, 198], [198, 219, 199], [219, 220, 199], [199, 220, 200], [220, 221, 200], [200, 221, 201], [221, 222, 201], [201, 222, 202], [222, 223, 202], [202, 223, 203], [223, 224, 203], [203, 224, 204], [224, 225, 204], [204, 225, 205], [225, 226, 205], [205, 226, 206], [226, 227, 206], [206, 227, 207], [227, 228, 207], [207, 228, 208], [228, 229, 208], [208, 229, 209], [229, 230, 209], [20, 41, 62, 83, 104, 125, 146, 167, 188, 209, 230], [20, 230, 210, 189, 168, 147, 126, 105, 84, 63, 42, 21, 0]]; polyhedron(points,faces);
Segmentation fault in mex with armadillo on Ubuntu 14.04 and matlab 2014Ra
I tried using mex files with armadillo linear algebra library. At first,I tried a very simple program as follows: Could anyone help me? %%%% matlab script %%%%%%% mex -larmadillo -lgfortran armaMex_demo.cpp X = randn(5,5); Y = randn(5,5); % Run the demo using X and Y Z = armaMex_demo(X,Y,3) %%%%%%%%%%%%% mex files %%%%%% #include "armaMex.hpp" #include <armadillo> using namespace arma; void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { // Check the number of input arguments. if (nrhs != 3) mexErrMsgTxt("Incorrect number of input arguments."); // Check type of input. if ( (mxGetClassID(prhs[0]) != mxDOUBLE_CLASS) || (mxGetClassID(prhs[1]) != mxDOUBLE_CLASS) ) mexErrMsgTxt("Input must me of type double."); // Check if input is real. if ( (mxIsComplex(prhs[0])) || (mxIsComplex(prhs[1])) ) mexErrMsgTxt("Input must be real."); // Create matrices X and Y from the first and second argument. mat X = armaGetPr(prhs[0]); mat Y = armaGetPr(prhs[1]); int c= armaGetScalar<int>(prhs[2]); // Our calculations require that matrices must be of the same size if ( size(X) != size(Y) ) mexErrMsgTxt("Matrices should be of same size."); // Perform calculations mat A = X + Y; mat B = X % Y; // % means element-wise multiplication in Armadillo mat D = inv(X)*Y; int ee = trace(X.i()*Y) + log(det(X)); // Create cube C with A and B as slices. cube C(A.n_rows, A.n_cols, 4); mat E = zeros<mat>(A.n_rows, A.n_cols); E(0,0) = ee; C.slice(0) = A; C.slice(1) = B; C.slice(2) = D; C.slice(3) = E; plhs[0] = armaCreateMxMatrix(C.n_rows, C.n_cols, C.n_slices); armaSetCubePr(plhs[0], C); return; } %%%%%%% the error %%%%%%%%% I tried X, Y with size 3*3, 4*4, it is OK But when I tried with 5*5 of matrix inversion, a failure occurred “Segmentation fault (core dumped)” and in matlab interface Segmentation violation detected at Thu Jul 30 16:04:53 2015 Configuration: Crash Decoding : Disabled Current Visual : 0x21 (class 4, depth 24) Default Encoding : UTF-8 GNU C Library : 2.19 stable MATLAB Architecture: glnxa64 MATLAB Root : /usr/local/MATLAB/R2014a MATLAB Version : 8.3.0.532 (R2014a) Operating System : Linux 3.16.0-45-generic #60~14.04.1-Ubuntu SMP Fri Jul 24 21:16:23 UTC 2015 x86_64 Processor ID : x86 Family 6 Model 60 Stepping 3, GenuineIntel Virtual Machine : Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode Window System : The X.Org Foundation (11600000), display :0 Fault Count: 4 Abnormal termination: Segmentation violation Register State (from fault): RAX = 0000000000000001 RBX = 0000000300000002 RCX = 0000000000000000 RDX = 00000000000027f8 RSP = 00007fd737ff71c0 RBP = 0000000000000000 RSI = 00007fd737ff9090 RDI = 0000000300000000 R8 = 0000000000027f40 R9 = 0000000000000002 R10 = 00007fd737ff9090 R11 = bff0000000000000 R12 = 0000000000000000 R13 = 0000000000000000 R14 = 0000003000000030 R15 = 00007fd737ff9090 RIP = 00007fd68e79ff3b EFL = 0000000000010202 CS = 0033 FS = 0000 GS = 0000 Stack Trace (from fault): [ 0] 0x00007fd68e79ff3b /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+15413051 mkl_blas_avx2_izamax+00000779 [ 1] 0x00007fd68ddae95f /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+04987231 mkl_lapack_zgetf2+00000255 [ 2] 0x00007fd68e1f9f63 /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+09490275 mkl_lapack_zgetrf_local+00001459 [ 3] 0x00007fd68e1f9c56 /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+09489494 mkl_lapack_zgetrf_local+00000678 [ 4] 0x00007fd68e1f9c56 /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+09489494 mkl_lapack_zgetrf_local+00000678 [ 5] 0x00007fd68e1f9c56 /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+09489494 mkl_lapack_zgetrf_local+00000678 [ 6] 0x00007fd68e1f9c56 /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+09489494 mkl_lapack_zgetrf_local+00000678 [ 7] 0x00007fd68da771de /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+01614302 mkl_lapack_zgetrf+00003822 [ 8] 0x00007fd68dc0ea8b /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+03283595 mkl_lapack_ao_zgetrf+00000107 [ 9] 0x00007fd68ddbae0b /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+05037579 mkl_lapack_zgesv+00000187 [ 10] 0x00007fd688d00a7b /home/weiwei/Work/PolSAR/PolSAR/PolSAR_code/mex_SLICPolSAR.mexa64+00105083 [ 11] 0x00007fd688cf9401 /home/weiwei/Work/PolSAR/PolSAR/PolSAR_code/mex_SLICPolSAR.mexa64+00074753 [ 12] 0x00007fd688cf51ca /home/weiwei/Work/PolSAR/PolSAR/PolSAR_code/mex_SLICPolSAR.mexa64+00057802 [ 13] 0x00007fd688cf0eb5 /home/weiwei/Work/PolSAR/PolSAR/PolSAR_code/mex_SLICPolSAR.mexa64+00040629 [ 14] 0x00007fd688cef8cd /home/weiwei/Work/PolSAR/PolSAR/PolSAR_code/mex_SLICPolSAR.mexa64+00035021 [ 15] 0x00007fd688cebb37 /home/weiwei/Work/PolSAR/PolSAR/PolSAR_code/mex_SLICPolSAR.mexa64+00019255 [ 16] 0x00007fd688ced570 /home/weiwei/Work/PolSAR/PolSAR/PolSAR_code/mex_SLICPolSAR.mexa64+00025968 mexFunction+00001660 [ 17] 0x00007fd74647272a /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00120618 mexRunMexFile+00000090 [ 18] 0x00007fd74646ea94 /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00105108 [ 19] 0x00007fd74646ffb4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00110516 [ 20] 0x00007fd745869ad9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670425 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00000697 [ 21] 0x00007fd744b062b4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04461236 [ 22] 0x00007fd744b07bc9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04467657 [ 23] 0x00007fd744b083fc /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04469756 [ 24] 0x00007fd7449826e3 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02873059 [ 25] 0x00007fd74499209e /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02936990 [ 26] 0x00007fd744992183 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02937219 [ 27] 0x00007fd744ac8172 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04206962 [ 28] 0x00007fd7448fd589 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02327945 [ 29] 0x00007fd744900167 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02339175 [ 30] 0x00007fd7448fe26f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02331247 [ 31] 0x00007fd7448feec4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02334404 [ 32] 0x00007fd74495c30b /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02716427 [ 33] 0x00007fd745869c5f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670815 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00001087 [ 34] 0x00007fd74494020e /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02601486 [ 35] 0x00007fd7448e11b0 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02212272 [ 36] 0x00007fd7448fc25f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02323039 [ 37] 0x00007fd744900167 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02339175 [ 38] 0x00007fd7448fe26f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02331247 [ 39] 0x00007fd7448feec4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02334404 [ 40] 0x00007fd74495c30b /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02716427 [ 41] 0x00007fd745869c5f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670815 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00001087 [ 42] 0x00007fd74492f135 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02531637 [ 43] 0x00007fd7448f60d9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02298073 [ 44] 0x00007fd7448f2dc7 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02284999 [ 45] 0x00007fd7448f3193 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02285971 [ 46] 0x00007fd74669cafc /usr/local/MATLAB/R2014a/bin/glnxa64/libmwbridge.so+00142076 [ 47] 0x00007fd74669d791 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwbridge.so+00145297 _Z8mnParserv+00000721 [ 48] 0x00007fd74f95392f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00489775 _ZN11mcrInstance30mnParser_on_interpreter_threadEv+00000031 [ 49] 0x00007fd74f934b6d /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00363373 [ 50] 0x00007fd74f934be9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00363497 [ 51] 0x00007fd744028d46 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwuix.so+00343366 [ 52] 0x00007fd74400b382 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwuix.so+00222082 [ 53] 0x00007fd7500a950f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02323727 [ 54] 0x00007fd7500a967c /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02324092 [ 55] 0x00007fd7500a557f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02307455 [ 56] 0x00007fd7500aa9b5 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02329013 [ 57] 0x00007fd7500aade7 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02330087 [ 58] 0x00007fd7500ab4c0 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02331840 _Z25svWS_ProcessPendingEventsiib+00000080 [ 59] 0x00007fd74f935098 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00364696 [ 60] 0x00007fd74f9353bf /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00365503 [ 61] 0x00007fd74f93028f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00344719 [ 62] 0x00007fd74e8de182 /lib/x86_64-linux-gnu/libpthread.so.0+00033154 [ 63] 0x00007fd74e60b47d /lib/x86_64-linux-gnu/libc.so.6+01025149 clone+00000109 Abnormal termination: Segmentation violation Register State (from fault): RAX = 0000000000000002 RBX = 0000000000000000 RCX = 0000001000000004 RDX = 000000000024875f RSP = 00007fd737ff9538 RBP = 0000000000000000 RSI = 00007fd6b6ddd500 RDI = 00007fd737ff9500 R8 = 0000001000000003 R9 = 0000000000000004 R10 = 0000000000000005 R11 = 00007fd74e698a30 R12 = 0000000000000000 R13 = 0000001000000005 R14 = 00007fd6b6ddd500 R15 = 0000000000000000 RIP = 00007fd68e7a0872 EFL = 0000000000010287 CS = 0033 FS = 0000 GS = 0000 Stack Trace (from fault): [ 0] 0x00007fd68e7a0872 /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+15415410 mkl_blas_avx2_idamax+00000626 [ 1] 0x00007fd68e05faae /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07809710 mkl_lapack_dgetf2+00000238 [ 2] 0x00007fd68e05f869 /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07809129 mkl_lapack_dgetrf_local+00001369 [ 3] 0x00007fd68e05f4ae /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07808174 mkl_lapack_dgetrf_local+00000414 [ 4] 0x00007fd68e05f4ae /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07808174 mkl_lapack_dgetrf_local+00000414 [ 5] 0x00007fd68e05f4ae /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07808174 mkl_lapack_dgetrf_local+00000414 [ 6] 0x00007fd68e05f4ae /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07808174 mkl_lapack_dgetrf_local+00000414 [ 7] 0x00007fd68dab6562 /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+01873250 mkl_lapack_dgetrf+00003810 [ 8] 0x00007fd66cf48a74 /home/weiwei/Work/PolSAR/PolSAR/utils/armadillo-5.200.2/mex_interface/armaMex_demo.mexa64+00035444 [ 9] 0x00007fd66cf43542 /home/weiwei/Work/PolSAR/PolSAR/utils/armadillo-5.200.2/mex_interface/armaMex_demo.mexa64+00013634 mexFunction+00002831 [ 10] 0x00007fd74647272a /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00120618 mexRunMexFile+00000090 [ 11] 0x00007fd74646ea94 /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00105108 [ 12] 0x00007fd74646ffb4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00110516 [ 13] 0x00007fd745869ad9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670425 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00000697 [ 14] 0x00007fd744b062b4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04461236 [ 15] 0x00007fd744b07bc9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04467657 [ 16] 0x00007fd744b083fc /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04469756 [ 17] 0x00007fd7449826e3 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02873059 [ 18] 0x00007fd74499209e /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02936990 [ 19] 0x00007fd744992183 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02937219 [ 20] 0x00007fd744ac8172 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04206962 [ 21] 0x00007fd7448fd589 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02327945 [ 22] 0x00007fd744900167 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02339175 [ 23] 0x00007fd7448fe26f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02331247 [ 24] 0x00007fd7448feec4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02334404 [ 25] 0x00007fd74495c30b /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02716427 [ 26] 0x00007fd745869c5f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670815 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00001087 [ 27] 0x00007fd74494020e /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02601486 [ 28] 0x00007fd7448e11b0 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02212272 [ 29] 0x00007fd7448fc25f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02323039 [ 30] 0x00007fd744900167 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02339175 [ 31] 0x00007fd7448fe26f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02331247 [ 32] 0x00007fd7448feec4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02334404 [ 33] 0x00007fd74495c30b /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02716427 [ 34] 0x00007fd745869c5f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670815 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00001087 [ 35] 0x00007fd74492f135 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02531637 [ 36] 0x00007fd7448f60d9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02298073 [ 37] 0x00007fd7448f2dc7 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02284999 [ 38] 0x00007fd7448f3193 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02285971 [ 39] 0x00007fd74669cafc /usr/local/MATLAB/R2014a/bin/glnxa64/libmwbridge.so+00142076 [ 40] 0x00007fd74669d791 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwbridge.so+00145297 _Z8mnParserv+00000721 [ 41] 0x00007fd74f95392f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00489775 _ZN11mcrInstance30mnParser_on_interpreter_threadEv+00000031 [ 42] 0x00007fd74f934b6d /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00363373 [ 43] 0x00007fd74f934be9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00363497 [ 44] 0x00007fd744028d46 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwuix.so+00343366 [ 45] 0x00007fd74400b382 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwuix.so+00222082 [ 46] 0x00007fd7500a950f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02323727 [ 47] 0x00007fd7500a967c /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02324092 [ 48] 0x00007fd7500a557f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02307455 [ 49] 0x00007fd7500aa9b5 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02329013 [ 50] 0x00007fd7500aade7 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02330087 [ 51] 0x00007fd7500ab4c0 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02331840 _Z25svWS_ProcessPendingEventsiib+00000080 [ 52] 0x00007fd74f935098 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00364696 [ 53] 0x00007fd74f9353bf /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00365503 [ 54] 0x00007fd74f93028f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00344719 [ 55] 0x00007fd74e8de182 /lib/x86_64-linux-gnu/libpthread.so.0+00033154 [ 56] 0x00007fd74e60b47d /lib/x86_64-linux-gnu/libc.so.6+01025149 clone+00000109 Abnormal termination: Segmentation violation Register State (from fault): RAX = 0000000000000001 RBX = 0000000000000000 RCX = 0000001000000004 RDX = 0000000000248729 RSP = 00007fd737ff9538 RBP = 0000000000000000 RSI = 00007fd6b6ddd6b0 RDI = 00007fd737ff9500 R8 = 0000001000000001 R9 = 0000000000000004 R10 = 0000000000000003 R11 = 00007fd74e698a30 R12 = 0000000000000000 R13 = 0000001000000005 R14 = 00007fd6b6ddd6b0 R15 = 0000000000000000 RIP = 00007fd68e7a0872 EFL = 0000000000010287 CS = 0033 FS = 0000 GS = 0000 Stack Trace (from fault): [ 0] 0x00007fd68e7a0872 /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+15415410 mkl_blas_avx2_idamax+00000626 [ 1] 0x00007fd68e05faae /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07809710 mkl_lapack_dgetf2+00000238 [ 2] 0x00007fd68e05f869 /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07809129 mkl_lapack_dgetrf_local+00001369 [ 3] 0x00007fd68e05f4ae /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07808174 mkl_lapack_dgetrf_local+00000414 [ 4] 0x00007fd68e05f4ae /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07808174 mkl_lapack_dgetrf_local+00000414 [ 5] 0x00007fd68e05f4ae /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07808174 mkl_lapack_dgetrf_local+00000414 [ 6] 0x00007fd68e05f4ae /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07808174 mkl_lapack_dgetrf_local+00000414 [ 7] 0x00007fd68dab6562 /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+01873250 mkl_lapack_dgetrf+00003810 [ 8] 0x00007fd66cf48a74 /home/weiwei/Work/PolSAR/PolSAR/utils/armadillo-5.200.2/mex_interface/armaMex_demo.mexa64+00035444 [ 9] 0x00007fd66cf43542 /home/weiwei/Work/PolSAR/PolSAR/utils/armadillo-5.200.2/mex_interface/armaMex_demo.mexa64+00013634 mexFunction+00002831 [ 10] 0x00007fd74647272a /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00120618 mexRunMexFile+00000090 [ 11] 0x00007fd74646ea94 /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00105108 [ 12] 0x00007fd74646ffb4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00110516 [ 13] 0x00007fd745869ad9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670425 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00000697 [ 14] 0x00007fd744b062b4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04461236 [ 15] 0x00007fd744b07bc9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04467657 [ 16] 0x00007fd744b083fc /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04469756 [ 17] 0x00007fd7449826e3 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02873059 [ 18] 0x00007fd74499209e /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02936990 [ 19] 0x00007fd744992183 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02937219 [ 20] 0x00007fd744ac8172 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04206962 [ 21] 0x00007fd7448fd589 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02327945 [ 22] 0x00007fd744900167 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02339175 [ 23] 0x00007fd7448fe26f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02331247 [ 24] 0x00007fd7448feec4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02334404 [ 25] 0x00007fd74495c30b /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02716427 [ 26] 0x00007fd745869c5f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670815 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00001087 [ 27] 0x00007fd74494020e /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02601486 [ 28] 0x00007fd7448e11b0 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02212272 [ 29] 0x00007fd7448fc25f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02323039 [ 30] 0x00007fd744900167 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02339175 [ 31] 0x00007fd7448fe26f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02331247 [ 32] 0x00007fd7448feec4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02334404 [ 33] 0x00007fd74495c30b /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02716427 [ 34] 0x00007fd745869c5f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670815 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00001087 [ 35] 0x00007fd74492f135 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02531637 [ 36] 0x00007fd7448f60d9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02298073 [ 37] 0x00007fd7448f2dc7 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02284999 [ 38] 0x00007fd7448f3193 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02285971 [ 39] 0x00007fd74669cafc /usr/local/MATLAB/R2014a/bin/glnxa64/libmwbridge.so+00142076 [ 40] 0x00007fd74669d791 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwbridge.so+00145297 _Z8mnParserv+00000721 [ 41] 0x00007fd74f95392f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00489775 _ZN11mcrInstance30mnParser_on_interpreter_threadEv+00000031 [ 42] 0x00007fd74f934b6d /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00363373 [ 43] 0x00007fd74f934be9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00363497 [ 44] 0x00007fd744028d46 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwuix.so+00343366 [ 45] 0x00007fd74400b382 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwuix.so+00222082 [ 46] 0x00007fd7500a950f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02323727 [ 47] 0x00007fd7500a967c /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02324092 [ 48] 0x00007fd7500a557f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02307455 [ 49] 0x00007fd7500aa9b5 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02329013 [ 50] 0x00007fd7500aade7 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02330087 [ 51] 0x00007fd7500ab4c0 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02331840 _Z25svWS_ProcessPendingEventsiib+00000080 [ 52] 0x00007fd74f935098 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00364696 [ 53] 0x00007fd74f9353bf /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00365503 [ 54] 0x00007fd74f93028f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00344719 [ 55] 0x00007fd74e8de182 /lib/x86_64-linux-gnu/libpthread.so.0+00033154 [ 56] 0x00007fd74e60b47d /lib/x86_64-linux-gnu/libc.so.6+01025149 clone+00000109 Abnormal termination: Segmentation violation Register State (from fault): RAX = 0000000000000002 RBX = 0000000000000000 RCX = 0000001000000004 RDX = 0000000000251169 RSP = 00007fd737ff9538 RBP = 0000000000000000 RSI = 00007fd6b6d984b0 RDI = 00007fd737ff9500 R8 = 0000001000000001 R9 = 0000000000000004 R10 = 0000000000000003 R11 = 00007fd74e698a30 R12 = 0000000000000000 R13 = 0000001000000005 R14 = 00007fd6b6d984b0 R15 = 0000000000000000 RIP = 00007fd68e7a0872 EFL = 0000000000010283 CS = 0033 FS = 0000 GS = 0000
Try to add the Armadillo cast used it in my code and it worked fine: `vec x = conv_to<vec>::from(armaGetPr(prhs[0],true));` For more info see: http://sigpack.sourceforge.net/build.html